diff --git a/homeassistant/components/verisure/__init__.py b/homeassistant/components/verisure/__init__.py index 62f41913862..dfd9d9cdc04 100644 --- a/homeassistant/components/verisure/__init__.py +++ b/homeassistant/components/verisure/__init__.py @@ -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) diff --git a/homeassistant/components/verisure/lock.py b/homeassistant/components/verisure/lock.py index ad9590d2524..1a81b437116 100644 --- a/homeassistant/components/verisure/lock.py +++ b/homeassistant/components/verisure/lock.py @@ -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: