sprocket-9 / hacs-nuvo-serial

Custom component to control a Nuvo Grand Concerto/Essentia G multi-zone amplifier via serial connection
MIT License
9 stars 1 forks source link

Automation Triggers Missing? #8

Closed The00Dustin closed 1 year ago

The00Dustin commented 1 year ago

In the Automation Triggers section, README.md indicates that I should be able to trigger automations using the keypads. When I choose any of my Essentia G media player entities as the device for a device trigger while creating a new automation, the Trigger dropdown remains disabled and indicates No triggers. As such, I can't trigger automations using my keypads. The documentation doesn't make it clear whether the availability of this option is limited to specific devices (for instance, perhaps it's a Grand Concerto only feature?) or configurations (for instance, even though this system never had more than 3 nuvonet devices, maybe all sources are configured as nuvonet devices?), so I am not certain if this is a limitation of my system, expected pending specific action I haven't taken, or an issue that might merit additional investigation.

sprocket-9 commented 1 year ago

Had a quick delve into this and looks like the device triggers stopped working after release v2.0.0 which had big changes to the device and entity hierarchy. When I get some time I'll look into redoing them, but AFAICR the HA documentation on triggers was very poor and the examples a bit head-scratchy. I don't have keypads myself and as no one else has reported this, you may be the only one trying to use these device triggers. Will likely do a beta release for you to test.

If you restart HA with debug logging enabled for nuvo_serial component you'll be able to see the nuvonet status for each Source on the system.

Add this to configuration.yaml and restarting HA:

logger:
  default: info
  logs:
    nuvo_serial: debug

Look for lines like this:

SourceConfiguration(source=2, enabled=True, name='Sonos', gain=4, nuvonet_source=False, short_name='SON')

To change the nuvonet status there's no way to do it through the HA component, either use https://github.com/sprocket-9/nuvo-serial or the Windows Nuvo Configuration SW.

The00Dustin commented 1 year ago

Are you sure it's broken? Based on the debug output, all of my sources are configured as nuvonet (even though my keypads can't change sources even on my nuvo tuner), so it seems I will need to change that. As such, if you aren't sure, it would make sense for me to test once I figure out how to make the change before any fixing is attempted. Even if you are sure, you might want to hold off until I've successfully made the change if you can't test it anyway, in case I'm unable to make the change and no one else is available to test.

sprocket-9 commented 1 year ago

Hmm actually it doesn't look too broken. When I looked at it the other day it was an old automation I'd created for testing that wasn't working, so I assumed it was the device hierarchy change at fault. But if I create a new automation using a Device trigger and one of my Zones as the device, I am able to select any of the three keypad events as the trigger, and get the automation to fire by calling the simulated button press service https://github.com/sprocket-9/hacs-nuvo-serial#keypad-services, so it looks ok.

Populating the trigger list dropdown doesn't actually depend on the current source for the chosen device/zone being set to a non-nuvonet source, the trigger list will be there regardless of the nuvonet source status, it just means if you have a nuvonet source selected for the zone, pressing the keypad buttons will not emit the keypad event out the serial port so HA won't receive it - according to the nuvo api docs anyway.

I can't seen anything in the trigger code which I made GC specific, so they should be in the list for your Essentia devices too. I am still on 2023.2 though, so possibly something on the HA side changed if you're running a more recent version.

Did you remove and reinstall the nuvo integration as recommended when v2.0.0 released?

The00Dustin commented 1 year ago

The drop-down is blank for my Nuvo media players, but populates if I choose a Z-Wave device, which seems to imply the device trigger stuff is missing or elsewhere. IIRC, I actually never had a version prior to v2.0.0, but I had issues getting it installed originally and removed and reinstalled a time or two on account of that (having seen those instructions and being pretty new to HA at the time).

I'm now on 2023.8.2 and this is still consistent.

I suppose it's also possible that I've somehow caused the issue trying to do things like change media player and/or source names. For instance, I connected my Yellow to Source 6 and tried to rename it to "Home Assistant" (possibly telling it to change the entity name at the same time). That lead to "Source 6" being a missing entity I couldn't delete through the GUI because it had no unique ID (or something like that). The missing entity eventually went away with some restart or reboot (possibly also paired with changing the name and entity name back and then renaming without the entity name change), but I had multiple experiences like that. I also still have to choose/enter "Source 6" in the source drop downs / automations now even though it says "Home Assistant" in the devices list. I'm half afraid to delete and re-add at this point because I don't want to configure it wrong when re-adding it or break my various automations. I haven't bothered with trying to change the nuvonet source settings since they aren't checked to begin with, but I can probably collect more information if you need anything specific.

sprocket-9 commented 1 year ago

Enable debug logging for nuvo_serial and send the log when you go through the process of trying to create a new automation trigger.

The00Dustin commented 1 year ago

It looks like these were the only log entries recorded while debug logging was enabled:

2023-08-18 12:17:34.882 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547855790656] Error handling message: Integration '' not found (unknown_error) Dustin from 192.168.XXX.XXX (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15) 2023-08-18 12:17:38.031 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547855790656] Error handling message: Unknown error (unknown_error) Dustin from 192.168.XXX.XXX (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/device_automation/init.py", line 372, in with_error_handling await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/device_automation/init.py", line 437, in websocket_device_automation_list_triggers await async_get_device_automations( File "/usr/src/homeassistant/homeassistant/components/device_automation/init.py", line 269, in async_get_device_automations for domain_results in await asyncio.gather( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/device_automation/init.py", line 228, in _async_get_device_automations_from_domain return await asyncio.gather( # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/nuvo_serial/device_trigger.py", line 40, in async_get_triggers registry = await entity_registry.async_get_registry(hass) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'homeassistant.helpers.entity_registry' has no attribute 'async_get_registry'

sprocket-9 commented 1 year ago

Looks like HA has deprecated async_get_registry from 2023.6 and I need fix this in the next release.

As a quick fix, on line 40 in /config/custom_components/nuvo_serial/device_trigger.py

change: registry = await entity_registry.async_get_registry(hass)

to: registry = await entity_registry.async_get(hass)

Does this get things working for you?

The00Dustin commented 1 year ago

No, the error still seems to be mostly the same, here is the end of it to show you what I mean by mostly (the other error also recurred, but after instead of before this time):

File "/config/custom_components/nuvo_serial/device_trigger.py", line 40, in async_get_triggers registry = await entity_registry.async_get(hass) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'homeassistant.helpers.entity_registry' has no attribute 'async_get_registry'

I did not restart or anything, but since it shows the new config in the error, I'm assuming I shouldn't have needed to...

sprocket-9 commented 1 year ago

Try it after a restart.

The00Dustin commented 1 year ago

Behavior remains the same. I noticed the errors still occur without debug enabled. It appears that only the longer error's last line changed (from AttributeError to TypeError):

TypeError: object EntityRegistry can't be used in 'await' expression

sprocket-9 commented 1 year ago

Ahh ok they've also changed it to a plain function.

Make it: registry = entity_registry.async_get(hass)

You'll need to restart HA after making changes to the file.

The00Dustin commented 1 year ago

That works. After that change (and another restart for good measure), the list populates including the button presses.

sprocket-9 commented 1 year ago

Fixed in release v2.0.3.