bezmi / homeassistant_jvc_projector_remote

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

Error While Setting Up JVCProjector #24

Open thegame3202 opened 1 year ago

thegame3202 commented 1 year ago

Love this addon! I disabled my projector config yesterday to troubleshoot something, and now it's not reconnecting to my projector. Was working great for months beforehand. I don't believe anything has changed on the projector, IP is the same, can telnet to IP and 20554. Not sure what I'm missing. Tried all available version(including master), and all have the same or very similar error. Any ideas? Here's the HASS log:

Error while setting up jvcprojector platform for remote
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvccommands.py", line 109, in __verify_ack
    ACK = sock.recv(COM_ACK_LENGTH)
TimeoutError: timed out

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 281, 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 40, in setup_platform
    JVCRemote(name, host, password, port, delay, timeout, retries),
  File "/config/custom_components/jvcprojector/remote.py", line 71, in __init__
    self._jvc = JVCProjector(self._conf_host, self._conf_password, self._conf_port, self._conf_delay, self._conf_timeout, self._conf_retries)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 55, in __init__
    self.validate_connection()
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 174, in validate_connection
    self._send_command(Commands.nullcmd)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 153, in _send_command
    command.write(jvc_sock)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvccommands.py", line 173, in write
    self.__verify_ack(sock, command)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvccommands.py", line 127, in __verify_ack
    raise JVCCommunicationError(
jvc_projector_remote.jvccommands.JVCCommunication
Error: Timeout when waiting for the specified ACK: `b'\x06\x89\x01\x00\x00\n'` for command: `nullcmd` with bytes: `b'!\x89\x01\x00\x00\n'`

Thank you!

thegame3202 commented 1 year ago

1.0.2 seems to work. 2.0.0a2 seems to break it. Must not have been up to date for a while... But I swear I was...

megapearl commented 1 year ago

I’m having the same problem, will test the 1.02 version this afternoon to see if it’s helping me too.

bezmi commented 1 year ago

Hi guys, what model projector do you have? Looks like it is not responding as expected to the nullcmd that is used to verify communications.

I have removed this check in the latest master branch (allow pre-release in hacs and select "master" for the version). Try it out and it if works, I'll backport it to v2.0.0. You'll have to set up via the config flow by adding the integration through the UI, not via configuration.yaml

megapearl commented 1 year ago

I have the JVC DLA-NP5 (lamp based instead of laser)

thegame3202 commented 1 year ago

Thanks Bezmi! I'm running an NX7 projector. I did also confirm I had 2.0.0.a3 before(when it was working). Checked my old backups and checked the manifest file.

New Master branch gives me the following when trying to add through the UI:

Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvccommands.py", line 109, in __verify_ack
    ACK = sock.recv(COM_ACK_LENGTH)
TimeoutError: timed out

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

Traceback (most recent call last):
  File "/config/custom_components/jvcprojector/config_flow.py", line 64, in async_step_user
    info = await validate_input(self.hass, user_input)
  File "/config/custom_components/jvcprojector/config_flow.py", line 42, in validate_input
    mac = format_mac(await hass.async_add_executor_job(projector.get_mac))
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 208, in get_mac
    return self._send_command(Commands.macaddr)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 156, in _send_command
    result = command.read(jvc_sock)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvccommands.py", line 188, in read
    self.__verify_ack(sock, command)
  File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvccommands.py", line 127, in __verify_ack
    raise JVCCommunicationError(
jvc_projector_remote.jvccommands.JVCCommunicationError: Timeout when waiting for the specified ACK: `b'\x06\x89\x01LS\n'` for command: `macaddr` with bytes: `b'?\x89\x01LSMA\n'`
thegame3202 commented 1 year ago

Interestingly, the master branch on Github shows the last commit 11 days ago. Maybe your change didn't sync over correctly? Or maybe I'm looking in the wrong place.

megapearl commented 1 year ago

Just installed 'latest' master release, still not connecting in my case.

image

How to troubleshoot?

bezmi commented 1 year ago

11 days is correct. I removed the bit of code mentioned in your initial error, so it no longer sends the nullcmd to check the connection. This time it's failing at the command that fetches the MAC address.

Are you saying that 2.0.0a3 worked previously but doesn't anymore? That's odd. v2.0.0 (no suffix) is actually more recent than the alpha ones. You can try that and report and error messages back here . I've also re-published the very first alpha - v2.0.0a1, same drill.

Sometimes the connection to the projector gets borked and it won't accept new communication from your Hass IP. This has worked to fix it for me in the past:

Full power cycle of the projector at the wall. Reset the network by assigning a (different) static IP in the projector network settings, apply these settings and then change them back to the previous values. Just don't pick the same IP as another device on the network.

Now as for why v1 works - there is no information fetched from the projector in this version. Only one way commands are sent to the device and all return communication is disregarded. v2a1, v2a2, v2a3 and v2.0.0 (latest) all rely on return info to get the state attributes and validate the connection in some way.

thegame3202 commented 1 year ago

11 days is correct. I removed the bit of code mentioned in your initial error, so it no longer sends the nullcmd to check the connection. This time it's failing at the command that fetches the MAC address.

Are you saying that 2.0.0a3 worked previously but doesn't anymore? That's odd. v2.0.0 (no suffix) is actually more recent than the alpha ones. You can try that and report and error messages back here . I've also re-published the very first alpha - v2.0.0a1, same drill.

Sometimes the connection to the projector gets borked and it won't accept new communication from your Hass IP. This has worked to fix it for me in the past:

Full power cycle of the projector at the wall. Reset the network by assigning a (different) static IP in the projector network settings, apply these settings and then change them back to the previous values. Just don't pick the same IP as another device on the network.

Now as for why v1 works - there is no information fetched from the projector in this version. Only one way commands are sent to the device and all return communication is disregarded. v2a1, v2a2, v2a3 and v2.0.0 (latest) all rely on return info to get the state attributes and validate the connection in some way.

Well you called that… changed the projector's IP by 1 digit and connected right away on Master! Strange…

Would be a good troubleshooting step to post in the readme! Thank you:-) I’ll send ya a donation in a sec here.

bezmi commented 1 year ago

Awesome and thanks in advance for the donation! I would suggest staying on the latest V2.0.0 until V2.1.0 which will be based on the current master.

Unfortunately these projectors seem to be quite quirky with the communications protocol - or some details are missing from the official protocol documentation. We always have hacky workarounds I guess 😅

thegame3202 commented 1 year ago

Awesome and thanks in advance for the donation! I would suggest staying on the latest V2.0.0 until V2.1.0 which will be based on the current master.

Unfortunately these projectors seem to be quite quirky with the communications protocol - or some details are missing from the official protocol documentation. We always have hacky workarounds I guess 😅

Absolutely! I would've never guessed it just didn't like the IP anymore haha. I'll rollback to the current v2.0. Thank you!

megapearl commented 1 year ago

Same here, by changing IP to another and back to the original, the problem disaappeared! Thanks!

image

bezmi commented 1 year ago

Great, I'll leave this open pending investigation into why it happens and any possible fixes.

megapearl commented 1 year ago

Thanks for your work and patience.

The problem seems to be back again :-(

This error originated from a custom integration.

Logger: custom_components.jvcprojector.remote
Source: custom_components/jvcprojector/remote.py:128
Integration: jvcprojector (documentation)
First occurred: 12:52:35 (1 occurrences)
Last logged: 12:52:35

The projector is not connected, cannot send command
Logger: jvc_projector_remote.jvcprojector
Source: /srv/homeassistant/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py:177
First occurred: 11:29:39 (167 occurrences)
Last logged: 12:52:39

Couldn't verify connection to projector at the specified address: cinema-projector.flissinger.local:20554.
This error originated from a custom integration.

Logger: custom_components.jvcprojector.remote
Source: custom_components/jvcprojector/remote.py:106
Integration: jvcprojector (documentation)
First occurred: 11:29:39 (167 occurrences)
Last logged: 12:52:39

Couldn't connect to the projector at the specified address: cinema-projector.flissinger.local:20554. Ensure the configuration is correct.
bezmi commented 1 year ago

Try staying on the master branch for a little bit and see how it goes with stability. It should be a little better for this particular issue. You can also try increasing the delay parameter.

megapearl commented 1 year ago

Switched back to the 'master' release and increased the delay.

Mr-Lucas commented 1 year ago

Not sure if I'm having the same issue, but I recently updated via HACS last night and my automations broke. I was on a 1. Release before.

What is odd is that I can turn the projector off and on via toggle in the overview, but when calling things like masking from the service in the developer section or a pre existing automation fail. If it was a connectivity thing, wouldn't everything fail?

I'll try changing the IP to something and back, and see if that helps. The integration was rock solid before the update.

Here are the attributes shown before I tried powering it on this morning.

image

Mr-Lucas commented 1 year ago

Okay I sorted it. The command names have changed. Instead of memory2 it is now memory-2

Thanks for keeping this alive. Expect some support coming your way.

bezmi commented 1 year ago

Yep, command format change was the reason the version numbering went from 1 -> 2. Appreciate the long term use and support :)

clint0r commented 1 year ago

I'm having issues connecting to a new NZ7/RS2100, and it seems like a bad handshake. I'm running v2.0 and JVC firmware 2.0. Any ideas where I might have a misconfiguration?

configuration.yaml remote:

Logs: Error while setting up jvcprojector platform for remote Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, 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 40, in setup_platform JVCRemote(name, host, password, port, delay, timeout, retries), File "/config/custom_components/jvcprojector/remote.py", line 72, in init self._jvc = JVCProjector(self._conf_host, self._conf_password, self._conf_port, self._conf_delay, self._conf_timeout, self._conf_retries) File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 55, in init self.validate_connection() File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 174, in validate_connection self._send_command(Commands.nullcmd) File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 140, in _send_command jvc_sock: socket.socket = self.handshake() File "/usr/local/lib/python3.10/site-packages/jvc_projector_remote/jvcprojector.py", line 125, in handshake raise JVCHandshakeError( _jvc_projectorremote.jvccommands.JVCHandshakeError: Projector did not reply with PJACK (received b'PJNAK' instead)**

bezmi commented 1 year ago

Hi, this could be caused by many things - when the projector sends "PJNAK", it's refusing to connect with you.

here are some suggestions:

If it still doesn't work, you should try the "master" branch (enable beta versions in HACS), which has a few updates and relies on a config flow to set up the projector rather than configuration.yaml.

clint0r commented 1 year ago

Hi, Changing settings in configuration.yaml did not work, but moving to the master branch with beta updates worked through the UI. Thanks for the quick response.