Use OptionsFlowWithReload in yalexs_ble (#151256)

This commit is contained in:
G Johansson
2025-08-27 20:14:31 +02:00
committed by GitHub
parent 8fc334b338
commit bad75222ed
2 changed files with 2 additions and 14 deletions

View File

@@ -129,24 +129,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: YALEXSBLEConfigEntry) ->
entry.async_on_unload(push_lock.register_callback(_async_state_changed)) entry.async_on_unload(push_lock.register_callback(_async_state_changed))
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
entry.async_on_unload( entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_shutdown) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_shutdown)
) )
return True return True
async def _async_update_listener(
hass: HomeAssistant, entry: YALEXSBLEConfigEntry
) -> None:
"""Handle options update."""
data = entry.runtime_data
if entry.title != data.title or data.always_connected != entry.options.get(
CONF_ALWAYS_CONNECTED
):
await hass.config_entries.async_reload(entry.entry_id)
async def async_unload_entry(hass: HomeAssistant, entry: YALEXSBLEConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: YALEXSBLEConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@@ -26,7 +26,7 @@ from homeassistant.config_entries import (
ConfigEntry, ConfigEntry,
ConfigFlow, ConfigFlow,
ConfigFlowResult, ConfigFlowResult,
OptionsFlow, OptionsFlowWithReload,
) )
from homeassistant.const import CONF_ADDRESS from homeassistant.const import CONF_ADDRESS
from homeassistant.core import callback from homeassistant.core import callback
@@ -315,7 +315,7 @@ class YalexsConfigFlow(ConfigFlow, domain=DOMAIN):
return YaleXSBLEOptionsFlowHandler() return YaleXSBLEOptionsFlowHandler()
class YaleXSBLEOptionsFlowHandler(OptionsFlow): class YaleXSBLEOptionsFlowHandler(OptionsFlowWithReload):
"""Handle YaleXSBLE options.""" """Handle YaleXSBLE options."""
async def async_step_init( async def async_step_init(