iloveicedgreentea / jvc_homeassistant

JVC Integration for Home Assistant
20 stars 4 forks source link

Remote loosing connection to NZ8 after latest update #42

Open roninf opened 2 months ago

roninf commented 2 months ago

Hi all,

since the latest update the integration that has been setup through the HA UI seems to loose connection to my NZ8. (setup using yaml is not accepted anymore?) All sensors showing unavailable and the remote is not able to turn on/off the device. Its only working after the initial setup (for a few seconds). At least its seems so...

Any Idea what i could/should check ?

BR

iloveicedgreentea commented 2 months ago

first confirm you are putting in the right info

entity name (same as your old entity name like nz8 or whatever) host IP password timeout seconds

If that doesnt work turn on debug logs and send me that

  default: warning
  logs:
    homeassistant.config_entries: debug
    custom_components.jvc_projectors: debug
roninf commented 2 months ago

Entity names are correct. :) I think it kind of solved by itself, but i guess it takes longer than usual to show/provide updates on states of the different sensors.

iloveicedgreentea commented 2 months ago

When you first go through the UI config, it attemps to connect to the PJ. If that fails, it should not add the integration. So if it added, it should be working. It usually takes up to a minute to refresh all the attributes. Can you post any logs that you see to make sure there are no errors on adding? And you are running 4.2.0?

iloveicedgreentea commented 2 months ago

4.2.1 should hopefully fix any outstanding issues. If you have any more feel free to reopen this

roninf commented 2 months ago

Thanks very much for the prompt response and your work on this integration!! Running on 4.2.0 i guess.

roninf commented 2 months ago

I still have massive issues using the integration not quite sure if these are the correct logs:

2024-02-26 16:02:34.697 WARNING (MainThread) [homeassistant.helpers.entity] Update of remote.theater_projector is taking over 10 seconds
2024-02-26 16:02:54.695 WARNING (MainThread) [homeassistant.components.remote] Updating jvc_projectors remote took longer than the scheduled update interval 0:00:30
2024-02-26 16:03:24.697 WARNING (MainThread) [homeassistant.components.remote] Updating jvc_projectors remote took longer than the scheduled update interval 0:00:30
2024-02-26 16:03:33.789 ERROR (MainThread) [JVC_projectors] Got a blank msg
2024-02-26 16:03:33.890 ERROR (MainThread) [JVC_projectors] Got a blank msg
2024-02-26 16:03:34.071 ERROR (MainThread) [custom_components.jvc_projectors.remote] Error getting attribute: Connection lost -- Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/command_runner.py", line 160, in _do_command
    await self.writer.drain()
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 389, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost

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

Traceback (most recent call last):
  File "/config/custom_components/jvc_projectors/remote.py", line 251, in update_worker
    value = await getter()
            ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/jvc_projector.py", line 440, in get_hdr_data
    return await self._get_attribute("hdr_data", ACKs.info_ack, HdrData)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/jvc_projector.py", line 314, in _get_attribute
    state, res = await self.commander.do_reference_op(command, ack)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/command_runner.py", line 268, in do_reference_op
    msg, success = await self.send_command(
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/command_runner.py", line 82, in send_command
    return await self._do_command(send_command, ack, command_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/command_runner.py", line 164, in _do_command
    raise ConnectionClosedError(err) from err
jvc_projector.error_classes.ConnectionClosedError: Connection lost
2024-02-26 16:03:54.701 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.theater_projector fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/jvc_projector/command_runner.py", line 160, in _do_command
    await self.writer.drain()
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 377, in drain
    raise exc
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1061, in write
    n = self._sock.send(data)
        ^^^^^^^^^^^^^^^^^^^^^
BrokenPipeError: [Errno 32] Broken pipe
iloveicedgreentea commented 2 months ago

Can you try 4.2.3? You will have to show beta versions in hacs.

roninf commented 2 months ago

I have used 4.2.3 now and it shows online right now but i have had this several times before. I will see and let you know.

roninf commented 2 months ago

So it happened again i was able to turn on the projector using the integration but afterwards the projector is kind of dead. Not reacting to any command neither using ip nor IR with the regular remote. While its still showing a picture you cant even turn it off. The only way is cutting power... weird.

Logs show:

Got a blank msg
Received ack: b'1\n\x06\x89\x01I' != expected ack: b'\x06\x89\x01IS\n'
Received ack: b'F\n@\x89\x01P' != expected ack: b'\x06\x89\x01IS\n'
Received ack: b'M40\n\x06\x89' != expected ack: b'\x06\x89\x01IS\n'
Received ack: b'\x01IN\n' != expected ack: b'\x06\x89\x01PM\n'
Error getting attribute: replace() argument 1 must be str, not bytes -- Traceback (most recent call last): File "/config/custom_components/jvc_projectors/remote.py", line 251, in update_worker value = await getter() ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/jvc_projector/jvc_projector.py", line 399, in get_software_version state.replace(ACKs.info_ack.value, b"") TypeError: replace() argument 1 must be str, not bytes 
Received ack: b'@\x89\x01PW3' != expected ack: b'\x06\x89\x01PW\n'
Got a blank msg
Received ack: b'\n' != expected ack: b'\x06\x89\x01PW\n'
Received ack: b'@\x89\x01PW1' != expected ack: b'\x06\x89\x01PW\n'

After powering it on again the remote (IR) is working again, the integration is not.

iloveicedgreentea commented 2 months ago

I am working on another rewrite to fix these issues. 2.4.3 has been stable for me but seems there are edge cases. Should be out this week or sooner

roninf commented 2 months ago

Ok thanks very much, i ll take a look then.

roninf commented 2 months ago

Right now i am on Beta 2.4.6 i guess and it seems that the remote can turn on the projector but does not get any feedback if the projector is on or not. So it shows offline while the projector is on.

Don`t know if its related but its shows a timeout now:

Logger: custom_components.jvc_projectors.remote
Quelle: custom_components/jvc_projectors/remote.py:116
Integration: JVC Projector ([Dokumentation](https://github.com/iloveicedgreentea/jvc_homeassistant))
Erstmals aufgetreten: 19:59:05 (1 Vorkommnisse)
Zuletzt protokolliert: 19:59:05
Timeout while trying to connect to 10.2.0.50

After reloading the integration, its shows the correct values.

iloveicedgreentea commented 2 months ago

please try 2.4.7 that should fix issues with attributes

roninf commented 2 months ago

Seems that it switches to online for a second, but its showing offline immediately again. After a few more seconds it shows all values correct. Hopefully its solved now :)

iloveicedgreentea commented 1 month ago

how about 4.2.9? Just had to rewrite a lot more logic but it seems to be stable for me now

roninf commented 1 month ago

I am at work right now, but i will update this afternoon and let you know.

roninf commented 1 month ago

By the way not related to this issue but might be usefull: for the NZ series you can now (software version 3) adjust laserpower from 0 to 100 not only in low/mid/high. Your approach is still working though....

iloveicedgreentea commented 1 month ago

yeah I implemented that a few version ago as laser_value I still have to do an overhaul of the readme

roninf commented 1 month ago

Ok so it seems to work fine fow now. But after turning on the projector it still shows on for second and the switched back to offline until (i guess) the jvc is polled again. After that its shows the correct values (i can live with that :) ) and it seems to be more responsive than the last versions.

iscofield commented 1 month ago

Having the same issue as this was working before the update and now for the life of me I can’t get it to connect to the projector at all. It always just says false with no updates even on 4.2.9.

Did you have to do anything else to get it to work?

roninf commented 1 month ago

No i have always been able to connect/configure (if i understood your issue correctly) the integration but it was not working anymore. Setup itself has more or less never been an issue for me. I have had issues that my projector kind of crashed hence not reacting to any command be it ip or ir. But that seem to be solved.

You could try to deinstall the integration completely and check wether there are still files left. Reboot HA and start over.

iscofield commented 1 month ago

I messed around with it more this morning and it can turn the projector on, but the problem is none of the attributes ever populate. I had the projector up and running last night and was uninstalling / reinstalling and rebooting HA but it never populated.

Same thing again this morning. I used the HA plugin to tun on the projector and 10 minutes later, the plugin still says the device is off, no attributes, etc.

Screenshot 2024-03-21 at 7 43 04 AM

Obviously the plugin can connect to the device as it can turn it on and it says connection alive is true. But for some reason, it's all the metadata that's broken?

iscofield commented 1 month ago

Worked on this more tonight and seems to be working now? After removing / reinstalling, using different entity names to ensure no older configuration was used, etc. I can turn it on, but the plug in immediately toggles off after turning the projector on. Then a few seconds later, now it displays all the information and is now triggering my MadVR envy automations again. Not sure what exactly did the trick but we're back in business! Thanks for the plugin!

Nope, this doesn't work. It was a red herring. If you use the plugin to turn on the projector, then it will eventually display the status, but if anything else turns the projector on, such as the IR remote or a Harmony remote, then the plugin never detects the projector is on. It's as if the entire plugin is gated behind it sending the power on command, otherwise it doesn't poll the projector?

roninf commented 1 month ago

Thats the same i described ealier on but i think one can live with it. Just did another test i turned on the projector using IR but the RemoteIntegration never reported the change its just stayed on showing offline....

iscofield commented 1 month ago

Hmm yes in my testing last night I was only doing it with the plugin but my normal setup is for my harmony remote to turn on the projector via IR. I’ll test that this morning to see if it’s the same for me. As that is what my issue was the first time is the projector was turned on via the harmony and the plugin never recognized it being on. If that’s the case, then it seems like the plugin only works if it has exclusive control and either the projector doesn’t report the status correctly depending on whether it’s controlled by IP or IR, or the plugin has some initialization logic that only fires when it sends the power on command vs just reporting what the projector is doing if it’s turned on via another source, which is my setup.

iscofield commented 1 month ago

Yea....I spoke to soon. Doesn't work if you power on the projector via IR. So for some reason, the most recent updates (whenever it switched from YAML config to UI config) it no longer works if the plugin doesn't seemingly have complete control and initiates the power on.

It's as if the entire plugin is gated behind it sending the power on command, otherwise it doesn't poll the projector?

iloveicedgreentea commented 1 month ago

Are you using the latest beta version? It should detect if its on, regardless of how its turned on as long as the integration has a connection open

iscofield commented 1 month ago

Yep, using 4.2.9. That's what I see in HACS for the current version when I click "redownload". I don't see a place on the actual integration page to check the installed version there, but I don't see why they'd be different.

iloveicedgreentea commented 1 month ago

in the integration page you can enable debug logs turn that on, restart, and then send me logs of you trying to turn it on and stuff. I think the debug log should persist with reboots

also what does the connection_active attribute say

iscofield commented 1 month ago

While the projector is off, the connection status is false. If I turn on the projector via the IR remote or my Harmony, it stays as false and never switches. If I turn on the projector via the plugin, then it will say true and everything will populate (after it sits for a bit, then says the remote is off, then comes back).

Will grab the debugs later today/tonight and send them over.

iloveicedgreentea commented 1 month ago

If you open file editor and go to custom_components/jvc_projectors/manifest.json can you post that and remote.py?

I want to make sure you have the right files. I am not able to replicate these issues on the latest version

It will open a connection when HA starts and only close it if you disable the integration. Do you have the other official JVC integration installed?

iscofield commented 1 month ago

I promise I'm not crazy, but now when trying to reproduce it with debug on, the plugin is now working and showing the correct power on state and triggering my other envy automations.

Here's manifest.json

{
  "domain": "jvc_projectors",
  "name": "JVC Projector",
  "config_flow": true,
  "documentation": "https://github.com/iloveicedgreentea/jvc_homeassistant",
  "requirements": [
    "pyjvc==4.3.51"
  ],
  "ssdp": [],
  "zeroconf": [],
  "homekit": {},
  "dependencies": [],
  "loggers": ["custom_components.jvc_projectors"],
  "codeowners": [
    "@iloveicedgreentea"
  ],
  "iot_class": "local_polling",
  "version": "4.2.1"
}

This doesn't make sense though as it says 4.2.1....but when I got to HACS I see 4.2.9?
remote.txt

(changed extension to .txt as .py isn't supported)

iloveicedgreentea commented 1 month ago

Yeah I just never updated that field it

Thats the right code. Let me know if the issue comes back and if so, what you were doing around that time. I haven't been able to replicate any issues so far

iscofield commented 1 month ago

Hopefully it was just a fluke! Really appreciate your help and for creating this!

mrpedaling commented 1 month ago

Hi, I've been following along as I had the same issues (nz7 fwiw) namely the deadlocking and odd attributes and log errors. 4.2.9 fixed all things here as well as far as I can tell. I did notice that after the hacs update and HA restart it showed connection status/signal status false... until the next power on of the projector. Then everything looked good.

The only thing I've noticed is the low latency attribute doesn't seem to be accurate compared to what the menus in the projector say. Feels minor, and I don't want to pull focus away from the OP's topic or this comment's point of "this version seems to fix things here afaict".

Carry on. Thanks for the code, improvements and maintenance!

roninf commented 1 month ago

While the projector is off, the connection status is false. If I turn on the projector via the IR remote or my Harmony, it stays as false and never switches. If I turn on the projector via the plugin, then it will say true and everything will populate (after it sits for a bit, then says the remote is off, then comes back).

Will grab the debugs later today/tonight and send them over.

Exactly the same for me.

roninf commented 1 month ago

The only thing I've noticed is the low latency attribute doesn't seem to be accurate compared to what the menus in the projector say.

I recognized that as well, i cant turn on low latency as well.

roninf commented 1 month ago

I have had the following error last nigh i don`t know if its related:

Logger: custom_components.jvc_projectors.remote
Quelle: custom_components/jvc_projectors/remote.py:219
Integration: JVC Projector ([Dokumentation](https://github.com/iloveicedgreentea/jvc_homeassistant))
Erstmals aufgetreten: 22. März 2024 um 23:52:24 (1 Vorkommnisse)
Zuletzt protokolliert: 22. März 2024 um 23:52:24
Unhandled exception in handle_queue: b'PW' is not a valid InputLevel

This morning i recognized the integration showing the NZ8 on while it was definitely off.

iloveicedgreentea commented 1 month ago

Can you try 4.4.03 please

roninf commented 1 month ago

I will check it out as soon as possible.

iloveicedgreentea commented 1 month ago

I will check it out as soon as possible.

4.4.04 now, or whatever the latest is at the time. I am actively developing stuff

roninf commented 1 month ago

Looks good so far. (4.4.04) Powered on immediately and showing the states as well as it seems. I will go on testing.

iloveicedgreentea commented 1 month ago

Cool I am working on fixing some other edge cases too (one person reported it). It seems that for some reason if you make custom sensors based on these attributes it somehow breaks stuff. Not sure why but I can't replicate it

iloveicedgreentea commented 1 month ago

4.4.05 fixes a potential issue with queues

roninf commented 1 month ago

Must correct myself, just turned off the projector using the remote. The integration still shows it running. Will do further testing tomorrow.

iloveicedgreentea commented 1 month ago

yeah the latest version should fix that

roninf commented 1 month ago

I am on 4.4.0.4. Just tried to turn off the integration but it stays on no matter how often i press the switch off button of the integration.

iloveicedgreentea commented 1 month ago

4.4.05 is the latest version as of now

roninf commented 1 month ago

Got it. Thanks!

roninf commented 1 month ago

I was able turn on and off the Projector once using the integration. A second time it did just nothing - unfortunately.