diff --git a/custom_components/jvc_projectors/manifest.json b/custom_components/jvc_projectors/manifest.json index 797a975..b9e96d8 100644 --- a/custom_components/jvc_projectors/manifest.json +++ b/custom_components/jvc_projectors/manifest.json @@ -4,7 +4,7 @@ "config_flow": false, "documentation": "https://www.home-assistant.io/integrations/jvc_projector", "requirements": [ - "jvc-projector-remote-improved==1.2.81" + "jvc-projector-remote-improved==2.0.0" ], "ssdp": [], "zeroconf": [], @@ -14,5 +14,5 @@ "@iloveicedgreentea" ], "iot_class": "local_polling", - "version": "1.2.81" + "version": "2.0.0" } \ No newline at end of file diff --git a/custom_components/jvc_projectors/remote.py b/custom_components/jvc_projectors/remote.py index 4862fee..d51e7cb 100644 --- a/custom_components/jvc_projectors/remote.py +++ b/custom_components/jvc_projectors/remote.py @@ -84,18 +84,11 @@ def __init__( self, name: str, host: str, - password: str, - timeout: str = None, jvc_client: JVCProjector = None, ) -> None: """JVC Init.""" self._name = name self._host = host - # Timeout for connections. Everything takes less than 3 seconds to run - if timeout is None: - self.timeout = 5 - else: - self.timeout = int(timeout) # use 5 second timeout, try to prevent error loops self._state = False self._ll_state = False @@ -103,6 +96,7 @@ def __init__( # otherwise JVC's server implementation will cancel the running command # and just confuse everything, then cause HA to freak out self._lock = asyncio.Lock() + self.jvc_client = jvc_client @property def should_poll(self): @@ -129,7 +123,6 @@ def extra_state_attributes(self): "power_state": self._state, "low_latency": self._ll_state, "host_ip": self._host, - "timeout": self.timeout, } @property diff --git a/info.md b/info.md index a812393..f7718a4 100644 --- a/info.md +++ b/info.md @@ -3,35 +3,75 @@ This is the Home Assistant JVC Component implementing my [JVC library](https://github.com/iloveicedgreentea/jvc_projector_improved) ## Features + All the features in my [JVC library](https://github.com/iloveicedgreentea/jvc_projector_improved) including: -* Power -* Picture Modes -* Laser power and dimming -* Low Latency meta-functions -* Optimal gaming and movie setting meta-functions -* and so on -## Home Assistant Setup +- Power +- Picture Modes +- Laser power and dimming +- Low Latency meta-functions +- Optimal gaming and movie setting meta-functions +- and so on + +Because everything is async, it will run each button/command in the order it received. so commands won't disappear from the queue due to JVCs PJ server requiring the handshake. It uses a single persistent connection so any delay you see is because of HA processing. + +## Installation + +This is currently only a custom component. Unlikely to make it into HA core because their process is just too burdensome. + +Install HACS, then install the component by adding this as a custom repo +https://hacs.xyz/docs/faq/custom_repositories + +You can also just copy all the files into your custom_components folder but then you won't have automatic updates. + +### Home Assistant Setup ```yaml # configuration.yaml remote: - platform: jvc_projectors - name: {friendly name} - password: {password} - host: {IP addr} - scan_interval: 30 # recommend 30-60. Power state will poll in this interval + name: { friendly name } + password: { password } + host: { IP addr } + timeout: { seconds } (optional) + scan_interval: 15 # recommend 15-30. Attributes will poll in this interval ``` ## Useful Stuff + I used this to re-create the JVC remote in HA. Add the YAML to your dashboard to get a grid which resembles most of the remote. Other functions can be used via remote.send_command. See the library readme for details. -*Note: the remote.send_command service currently expects a list and the HA UI does not seem to allow you to specify a YAML list in the command param to the entity. If you use UI mode, you will break your config and get an index out of range error* -*Make sure to change your entity ID* +Add this sensor to your configuration.yml. Replace the nz7 with the name of your entity. Restart HA. + +```yaml +sensor: + platform: template + sensors: + jvc_low_latency: + value_template: > + {% if is_state('remote.nz7', 'on') %} + {% if states.remote.nz7.attributes.low_latency == false %} + Off + {% elif states.remote.nz7.attributes.low_latency == true %} + On + {% endif %} + {% else %} + Off + {% endif %} +``` + +Add this to lovelace ```yaml type: grid cards: + - type: button + name: Power + show_icon: false + entity: remote.nz7 + show_state: true + show_name: true + icon: mdi:power - type: button tap_action: action: call-service @@ -43,18 +83,12 @@ cards: name: Info hold_action: action: none - - type: button - tap_action: - action: toggle - show_icon: false - type: button tap_action: action: call-service service: remote.send_command service_data: - command: - - menu - - up + command: menu,up target: entity_id: remote.nz7 show_name: false @@ -62,19 +96,12 @@ cards: icon: mdi:arrow-up hold_action: action: none - - type: button - tap_action: - action: toggle - show_icon: false - show_name: false - type: button tap_action: action: call-service service: remote.send_command service_data: - command: - - menu - - menu + command: menu,menu target: entity_id: remote.nz7 show_name: true @@ -86,14 +113,22 @@ cards: tap_action: action: toggle show_icon: false + - type: button + tap_action: + action: none + show_icon: false + entity: sensor.jvc_low_latency + show_name: true + show_state: true + name: Low Latency + hold_action: + action: none - type: button tap_action: action: call-service service: remote.send_command service_data: - command: - - menu - - left + command: menu,left target: entity_id: remote.nz7 show_name: false @@ -103,9 +138,7 @@ cards: action: call-service service: remote.send_command service_data: - command: - - menu - - ok + command: menu, ok target: entity_id: remote.nz7 name: OK @@ -115,13 +148,16 @@ cards: action: call-service service: remote.send_command service_data: - command: - - menu - - right + command: menu, right target: entity_id: remote.nz7 show_name: false icon: mdi:arrow-right + - type: button + tap_action: + action: toggle + show_icon: false + show_name: false - type: button tap_action: action: toggle @@ -131,25 +167,17 @@ cards: action: call-service service: remote.send_command service_data: - command: - - menu - - back + command: menu,back target: entity_id: remote.nz7 name: Back show_icon: false - - type: button - tap_action: - action: toggle - show_icon: false - type: button tap_action: action: call-service service: remote.send_command service_data: - command: - - menu - - down + command: menu,down target: entity_id: remote.nz7 show_name: false @@ -161,41 +189,46 @@ cards: - type: button tap_action: action: toggle - name: Setup show_icon: false - show_name: false - type: button tap_action: - action: toggle + action: call-service + service: jvc_projectors.gaming_mode_hdr + service_data: {} + target: + entity_id: remote.nz7 show_icon: false + show_name: true + hold_action: + action: none + name: Game HDR - type: button tap_action: action: call-service - service: remote.send_command - service_data: - command: - - power - - 'off' + service: jvc_projectors.gaming_mode_sdr + service_data: {} target: entity_id: remote.nz7 show_icon: false - name: 'Off' + name: Game SDR - type: button tap_action: - action: toggle + action: call-service + service: jvc_projectors.hdr_picture_mode + service_data: {} + target: + entity_id: remote.nz7 show_icon: false + name: Film HDR - type: button tap_action: action: call-service - service: remote.send_command - service_data: - command: - - power - - 'on' + service: jvc_projectors.sdr_picture_mode + service_data: {} target: entity_id: remote.nz7 - name: 'On' show_icon: false + name: Film SDR - type: button tap_action: action: toggle diff --git a/readme.md b/readme.md index fe41c38..f7718a4 100644 --- a/readme.md +++ b/readme.md @@ -13,13 +13,14 @@ All the features in my [JVC library](https://github.com/iloveicedgreentea/jvc_pr - Optimal gaming and movie setting meta-functions - and so on - +Because everything is async, it will run each button/command in the order it received. so commands won't disappear from the queue due to JVCs PJ server requiring the handshake. It uses a single persistent connection so any delay you see is because of HA processing. ## Installation -This is currently only a custom component. Working on getting this into HA Core +This is currently only a custom component. Unlikely to make it into HA core because their process is just too burdensome. -Install HACS, then install the component by adding this as a custom repo https://hacs.xyz/docs/faq/custom_repositories +Install HACS, then install the component by adding this as a custom repo +https://hacs.xyz/docs/faq/custom_repositories You can also just copy all the files into your custom_components folder but then you won't have automatic updates. @@ -32,8 +33,8 @@ remote: name: { friendly name } password: { password } host: { IP addr } - timeout: { seconds } - scan_interval: 30 # recommend 30-60. Power state will poll in this interval + timeout: { seconds } (optional) + scan_interval: 15 # recommend 15-30. Attributes will poll in this interval ``` ## Useful Stuff