kvj / hass_nuki_ng

Better support for Nuki devices in the Home Assistant
MIT License
184 stars 36 forks source link

Error in log: "None is not a valid LockStates" #168

Open poughkeepsee opened 11 months ago

poughkeepsee commented 11 months ago

I've had this error in my log for months now, and I can't understand the reason or how to fix it. As far as I can tell, the lock is reporting a None state that can't identified/handled by the component. I have a v1 lock + bridge.

Appreciate any help possible. Log entry below.

2023-12-08 19:49:11.565 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 243, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 399, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 479, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 751, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/nuki_ng/sensor.py", line 141, in state
    return str(self.get_state())
               ^^^^^^^^^^^^^^^^
  File "/config/custom_components/nuki_ng/sensor.py", line 144, in get_state
    lock_state = LockStates(self.last_state.get("state"))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: None is not a valid LockStates
sven-debug commented 8 months ago

Dears,

that one is still open. When do you expect to issue an updated version? the integration is still pumping in a load of error messages in my installation like:

`Logger: homeassistant Source: custom_components/nuki_ng/sensor.py:96 Integration: Nuki Lock (documentation, issues) First occurred: 12. Februar 2024 um 16:43:40 (714 occurrences) Last logged: 09:01:09

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 412, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 492, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/config/custom_components/nuki_ng/sensor.py", line 100, in state return self.native_value ^^^^^^^^^^^^^^^^^ File "/config/custom_components/nuki_ng/sensor.py", line 96, in native_value return self.data.get("bridge_info", {}).get("rssi") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'`

Any help highly appreciated!