bezmi / homeassistant_jvc_projector_remote

Custom components for homeassistant
Apache License 2.0
14 stars 11 forks source link

Implement Default state when Projecter is without Power #13

Closed lord-drinkalot closed 1 year ago

lord-drinkalot commented 1 year ago

When the Projector is powered off and I reset my HA Instance, the Integration fails to start. And I cannot get it to work without powering on the PJ and resetting HA.

Maybe implement a ping if the IP is reachable, if not update with a "not connected" state and skip the rest. image

`Log Details (ERROR) Logger: homeassistant.components.remote Source: custom_components/jvcprojector/remote.py:62 Integration: Remote (documentation, issues) First occurred: 14:11:39 (1 occurrences) Last logged: 14:11:39

Error while setting up jvcprojector platform for remote Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 79, in __connect jvc_sock.connect((self.host, self.port)) OSError: [Errno 113] Host is unreachable

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 59, in init self._send_command(Commands.nullcmd) File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 149, in _send_command jvc_sock: socket.socket = self.handshake() File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 106, in handshake jvc_sock = self.connect() File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 93, in connect jvc_sock = self.connect(retry + 1) File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 93, in connect jvc_sock = self.connect(retry + 1) File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 93, in connect jvc_sock = self.connect(retry + 1) [Previous line repeated 8 more times] File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 96, in connect raise JVCCannotConnectError( jvc_projector_remote.jvccommands.JVCCannotConnectError: Could not establish connection to projector

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/jvcprojector/remote.py", line 36, in setup_platform JVCRemote(name, host, password, port, delay, timeout, retries), File "/config/custom_components/jvcprojector/remote.py", line 62, in init self._jvc = JVCProjector(host, password, port, delay, timeout, retries) File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 61, in init raise JVCConfigError( jvc_projector_remote.jvccommands.JVCConfigError: Couldn't verify connection to projector at the specified address: 192.168.1.49:20554. Make sure the host and port are set correctly and control4 is turned off in projector settings`

bezmi commented 1 year ago

that is definitely something I can do and a good catch. With the model I've got, I never ran into this issue as the projector has no problem responding to the connection test command when powered off.

We should have a catch for the "JVCConfigError" in the initialisation for the remote entity and output a Log error messsage instead if the connection fails. This way, the entity can still be created.

I appreciate the report. If you have the ability, could you please test with the base python library to answer the following (ensure homeassistant component is disabled):

EDIT: I just realised, you might be referring to "powered off" as in off at the wall, not just in standby. If this is the case, no need for the troubleshooting steps above and the initialisation error handling would fix this.

I am just concerned if some projectors don't respond to the nullcmd command when in standby.

lord-drinkalot commented 1 year ago

Correct, no Power at all, I use a APC PDU and control it with SNMP. So If I don't watch something, the outlet is disabled and the PJ is not in Standby.

If the PJ is in Standby then everything works as expected.

bezmi commented 1 year ago

This should work now.