kvj / hass_nuki_ng

Better support for Nuki devices in the Home Assistant
MIT License
167 stars 32 forks source link

Better Doorbell Suppression Support #146

Closed GNeras closed 1 year ago

GNeras commented 1 year ago

Building on #126, I implemented and tested a select entity for doorbell suppression and separate switches for the different suppression settings. The switch entities are disabled by default so the user can choose to enable those if they prefer them over the select entity.

This also corrects the bit that has to be flipped for the previously existing switch. It seems the documentation from Nuki is slightly wrong and that's why the switch was changing the Continuous Mode ring suppression as seen here.

I implemented this because I needed to have this functionality, but feel free to use my code in #126 instead.

Keep in mind that I'm not very familiar with git, GitHub, python or Home Assistant development, so I apologize if I did something wrong.

zimjjan commented 1 year ago

worked okay, but now:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant
Source: custom_components/nuki_ng/sensor.py:220
Integration: Nuki Lock (documentation, issues)
First occurred: 19. März 2023 um 23:13:06 (243 occurrences)
Last logged: 18:27:20

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 330, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 135, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 390, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 603, in _async_write_ha_state
    attr.update(self.extra_state_attributes or {})
  File "/config/custom_components/nuki_ng/sensor.py", line 220, in extra_state_attributes
    "timestamp": datetime.fromisoformat(timestamp) if not None else None,
TypeError: fromisoformat: argument must be str
zimjjan commented 1 year ago

also the following error occurs:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/nuki_ng/sensor.py:220
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 18:26:14 (1 occurrences)
Last logged: 18:26:14

[140580569104784] fromisoformat: argument must be str
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 961, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 726, in _handle_entity_call
    await result
  File "/config/custom_components/nuki_ng/switch.py", line 143, in async_turn_off
    await self.update_doorbell_suppression(self.doorbellSuppression & (~self._suppression))
  File "/config/custom_components/nuki_ng/__init__.py", line 204, in update_doorbell_suppression
    await self.coordinator.update_config(self.device_id, "openerAdvancedConfig", dict(doorbellSuppression=new_value))
  File "/config/custom_components/nuki_ng/nuki.py", line 536, in update_config
    self.async_set_updated_data(data)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 360, in async_set_updated_data
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 135, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 390, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 603, in _async_write_ha_state
    attr.update(self.extra_state_attributes or {})
  File "/config/custom_components/nuki_ng/sensor.py", line 220, in extra_state_attributes
    "timestamp": datetime.fromisoformat(timestamp) if not None else None,
TypeError: fromisoformat: argument must be str
GNeras commented 1 year ago

It looks like this is the same as #106, which will be fixed by #132.

Se7enair commented 1 year ago

Just tested it. It works flawlessly together with #132.

kvj commented 1 year ago

Thanks for testing, everyone. Should I merge it and release a new version?

Se7enair commented 1 year ago

From my point of view, yes.

zimjjan commented 1 year ago

Seems okay for me, too. Make sure to merge #146 and #132 :)

kvj commented 1 year ago

New release: https://github.com/kvj/hass_nuki_ng/releases/tag/0.4.0

moeffju commented 1 year ago

🎉