Verisure: propagate lock code digits configuration immediately (#99241)
This commit is contained in:
parent
b403cb41c0
commit
de30712d76
2 changed files with 15 additions and 5 deletions
|
@ -48,9 +48,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
# Set up all platforms for this device/entry.
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
# Update options
|
||||
entry.async_on_unload(entry.add_update_listener(update_listener))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def update_listener(hass: HomeAssistant, entry: ConfigEntry):
|
||||
"""Handle options update."""
|
||||
# Propagate configuration change.
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
coordinator.async_update_listeners()
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload Verisure config entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
|
|
@ -70,9 +70,6 @@ class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEnt
|
|||
|
||||
self.serial_number = serial_number
|
||||
self._state: str | None = None
|
||||
self._digits = coordinator.entry.options.get(
|
||||
CONF_LOCK_CODE_DIGITS, DEFAULT_LOCK_CODE_DIGITS
|
||||
)
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
|
@ -111,8 +108,11 @@ class VerisureDoorlock(CoordinatorEntity[VerisureDataUpdateCoordinator], LockEnt
|
|||
|
||||
@property
|
||||
def code_format(self) -> str:
|
||||
"""Return the required six digit code."""
|
||||
return "^\\d{%s}$" % self._digits
|
||||
"""Return the configured code format."""
|
||||
digits = self.coordinator.entry.options.get(
|
||||
CONF_LOCK_CODE_DIGITS, DEFAULT_LOCK_CODE_DIGITS
|
||||
)
|
||||
return "^\\d{%s}$" % digits
|
||||
|
||||
@property
|
||||
def is_locked(self) -> bool:
|
||||
|
|
Loading…
Add table
Reference in a new issue