FutureTense / keymaster

Home Assistant integration for managing Z-Wave enabled locks
MIT License
239 stars 45 forks source link

ISSUE: Locks Not Updating #369

Closed inaxsesable closed 5 months ago

inaxsesable commented 5 months ago

Describe the bug No lock actions are being performed. Codes stuck as adding, deleting. I just noticed this after the update to Home Assistant update to 2024.6.0

Environment (please complete the following information):

Logs 2024-06-06 10:04:54.116 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:04:55.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:04:59.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:00.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:04.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:04.386 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client. 2024-06-06 10:05:05.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:06.393 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client. 2024-06-06 10:05:09.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:10.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:14.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:15.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:19.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:20.691 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:24.116 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:25.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:29.116 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:30.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:34.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:34.386 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client. 2024-06-06 10:05:35.692 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:36.394 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client. 2024-06-06 10:05:39.116 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:40.691 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True) 2024-06-06 10:05:44.115 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True)

Screenshots image

Additional context

inaxsesable commented 5 months ago

It is doing this for more than 1 lock.

DerekF35 commented 5 months ago

I am also having the same issue after updating to 2024.6.0. Mine is manifesting itself the same as yours, but my watchman is also reporting unavailable locks.

Z-Wave integration name: zwave_js UI Lock: Yale YRD216 - zwave

Example:

- id: sensor.frontdoor_code_slot_9
state: unavail
friendly_name: 'frontdoor: Code Slot 9'
occurrences: packages/keymaster/frontdoor/frontdoor_keymaster_9.yaml:177,269

I attempted to go through the rebuild process to reconfigure keymaster, but that did not improve matters. Lock is operating fine through HA without using keymaster functionality.

saquam commented 5 months ago

I am having the same issue after updating HA.

firstof9 commented 5 months ago

Did you guys update your zwavejs UI per the breaking changes in 2024.6.x ?

saquam commented 5 months ago

Did you guys update your zwavejs UI per the breaking changes in 2024.6.x ?

I am one the current version of zwavejs ui

DerekF35 commented 5 months ago

I am on Z-Wave JS UI add-on version 3.7.1 which meets the criteria of >=3.4.2. I confirmed it is also running zwave-js-server 1.35.0 in the add-on

firstof9 commented 5 months ago

I don't know these version numbers you're throwing around here's what zwavejs-ui says in the info button for mine:

zwave-js-ui: 9.13.4.e803879
zwave-js: 12.10.0
firstof9 commented 5 months ago

Messages like:

2024-06-06 10:05:06.393 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client.

indicate no connection to zwavejs

DerekF35 commented 5 months ago

Hovering over the info button provides the following, which is below your setup:

Z-Wave JS UI: 9.13.3 Z-Wave JS: 12.9.1

I have zwave-ui installed using the community add-in ( https://github.com/hassio-addons/addon-zwave-js-ui/releases/tag/v3.7.1 ), which may be the disconnect. v3.7.1 of the add-in is the latest version.

The breaking change in the release notes point to the backwards incompatibility change being with zwave-js-server: You must use zwave-js-server 1.35.0 or greater (schema 35).

Drilling further into the info screen of zwave-ui, it confirms that the 3.7.1 community add on version does ship with zwave-js-server 1.35.0. Based on the release note requirements, it appears the criteria is being met through the add-on, however there does still appear to be a disconnect somewhere with all the versioning and ways you can install zwave-ui.

firstof9 commented 5 months ago

I'm not getting any of these errors.

DerekF35 commented 5 months ago

We maybe need to wait until the zwave-ui community add-on bumps their zwave-js-ui dependency to at least 9.13.4, which will bump zwave-ui to 12.10.0. That would align the versions with what you're witness on your end and is working correctly.

I'm curious if others having the same issues are also setup with zwave-ui using the community addon.

saquam commented 5 months ago

I am using the community addon.

DerekF35 commented 5 months ago

The zwave-js-ui bump to 9.13.4 has made it to the main branch of addon-zwave-js-ui.

https://github.com/hassio-addons/addon-zwave-js-ui/commit/12463a8407dce78dff5d232653d56cf973cde3d6

Hopefully a release is coming soon and this will fix community addon users.

bikemike commented 5 months ago

I also have this issue after updating to 2024.6.0

zwave-js-ui: 9.13.4 zwave-js: 12.10.0

Log shows: [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client.

bikemike commented 5 months ago

I think this issue is caused by this change:

https://github.com/home-assistant/core/pull/117261

Uses config entry runtime_data instead of hass.data[DOMAIN][config_entry.entry_id]

bikemike commented 5 months ago

I was able to get this working by manually changing two files to use config entry runtime_data for the zwave js integration instead of the hass.data[DOMAIN][config_entry.entry_id] method. I know next to nothing about coding for home assistant so I'm not sure if this is the proper solution.

custom_components/keymaster/binary_sensor.py (around line 134)

        try:
            zwave_entries = self.hass.config_entries.async_entries(ZWAVE_JS_DOMAIN)
            zwave_entry = zwave_entries[0] if zwave_entries else None
            client = zwave_entry.runtime_data[ZWAVE_JS_DATA_CLIENT]
        except AttributeError:
            _LOGGER.debug("Can't access Z-Wave JS data client.")
            self._attr_is_on = False
            return

custom_components/keymaster/helpers.py (around line 150)

    try:
        zwave_entries = hass.config_entries.async_entries(ZWAVE_JS_DOMAIN)
        zwave_entry = zwave_entries[0] if zwave_entries else None
        client = zwave_entry.runtime_data[ZWAVE_JS_DATA_CLIENT]
    except AttributeError:
        _LOGGER.debug("Can't access Z-Wave JS data client.")
rmangaha commented 5 months ago

I can confirm the changes worked for me. Running HA OS: zwave-js-ui: 9.13.3 zwave-js: 12.9.1

I was able to get this working by manually changing two files to use config entry runtime_data for the zwave js integration instead of the hass.data[DOMAIN][config_entry.entry_id] method. I know next to nothing about coding for home assistant so I'm not sure if this is the proper solution.

firstof9 commented 5 months ago

@raman325 this look like a valid solution? Something tells me it could break if the integration get's adjusted?

beyondunreal79 commented 5 months ago

Same issue here. My unlock notifications also stopped working after core update 2024.5.5

tykeal commented 5 months ago

FYI Zwave-JS UI updated and it's still broken with the update so the above fix might be what's needed. I haven't tested it myself yet.

tykeal commented 5 months ago

I've tried the code that @bikemike posted. It's not working for me. I'm not certain why, but I added some debug statements to see what's going on with it.

To be specific I modified the code for the keymaster/binary_sensor.py to be as follows:

        try:
            zwave_entries = self.hass.config_entries.async_entries(ZWAVE_JS_DOMAIN)
            _LOGGER.debug(f"zwave_entries = {zwave_entries}")
            zwave_entry = zwave_entries[0] if zwave_entries else None
            _LOGGER.debug(f"zwave_entry = {zwave_entry}")
            client = zwave_entry.runtime_data[ZWAVE_JS_DATA_CLIENT]
        except AttributeError:
            _LOGGER.debug("Can't access Z-Wave JS data client.")
            self._attr_is_on = False
            return
2024-06-08 08:11:13.272 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] zwave_entries = [<ConfigEntry entry_id=658434ec98836e28f73256005409b7c6 version=1 domain=zwave_js title=HubZ Smart Home Controller state=ConfigEntryState.NOT_LOADED unique_id=10C4:8A2A_5160036A_Silicon Labs_HubZ Smart Home Controller - HubZ Z-Wave Com Port>, <ConfigEntry entry_id=1b329c8f9004774521a6d500f12d26f2 version=1 domain=zwave_js title=Z-Wave JS state=ConfigEntryState.LOADED unique_id=4108608036>]
2024-06-08 08:11:13.272 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] zwave_entry = <ConfigEntry entry_id=658434ec98836e28f73256005409b7c6 version=1 domain=zwave_js title=HubZ Smart Home Controller state=ConfigEntryState.NOT_LOADED unique_id=10C4:8A2A_5160036A_Silicon Labs_HubZ Smart Home Controller - HubZ Z-Wave Com Port>
2024-06-08 08:11:13.272 DEBUG (MainThread) [custom_components.keymaster.binary_sensor] Can't access Z-Wave JS data client.

I've got a HubZ combo stick and it seems to be showing up with two different entries. I've tried both of them and I get the same issue.

I don't know if it has anything to do with the state=ConfigEntryState.NOT_LOADED that I'm seeing in the logs. I tried adding a debug output of a dir() on the zwave_entry object but that apparently is causing the AttributeError that trying to set the client object is also causing.

I do know that ZWave is working correctly for core components that are using ZWave. It's just Keymaster (and Lock Code Manager) having this issue.

firstof9 commented 5 months ago

@tykeal if you have time, in https://github.com/FutureTense/keymaster/pull/372 I put a code suggestion, if you'd like to see if that'd work in your situation.

Likely need to add an import as well:

from homeassistant.config_entries import ConfigEntryState
tykeal commented 5 months ago

@firstof9 Just gave it a whirl. Needed some extra help to work. I've added my own review on #372 related to what needs to change. But, it works after this.

firstof9 commented 5 months ago

Thanks @tykeal I'll have a look when I get home.

firstof9 commented 5 months ago

Thanks again @Snuffy2 for the PR and @tykeal for testing changes/feedback.

rcdailey commented 5 months ago

I have the latest update but I'm still experiencing the symptoms shared here. I ended up just modifying the codes myself in zwavejs since my trip is coming up soon; but it's unfortunate that I can't use keymaster to do it.

inaxsesable commented 5 months ago

The latest update to Keymaster this morning has fixed the issue for me. Thanks Everyone!

DAVe3283 commented 5 months ago

372 didn't fix this for me. I am in a probably unusual situation where I have 2 separate Z-Wave JS networks, one running under the Z-Wave JS add-on, and the other under the Z-Wave JS UI add-on, each with their own Z-Wave stick. The door lock is connected to Z-Wave JS UI, which appears to load 2nd.

zwave_loaded_entries = [
    entry
    for entry in self.hass.config_entries.async_entries(ZWAVE_JS_DOMAIN)
    if entry.state == ConfigEntryState.LOADED
]
zwave_entry = zwave_loaded_entries[0] if zwave_loaded_entries else None

That appears to grab a list of all the loaded Z-Wave JS entries, then arbitrarily pick the first one. On most people's setup, there would just be one, so that is fine. But in my case, there are 2 loaded & running controllers, but only one contains the lock. I think the code needs to find which entry contains the lock and use that one, not the first one. I have no idea how to do that or I would submit a PR.