mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Use OptionsFlowWithReload in Proximity (#149136)
This commit is contained in:
parent
27787e0679
commit
bd7cef92c7
@ -43,17 +43,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ProximityConfigEntry) ->
|
|||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, [Platform.SENSOR])
|
await hass.config_entries.async_forward_entry_setups(entry, [Platform.SENSOR])
|
||||||
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ProximityConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ProximityConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
return await hass.config_entries.async_unload_platforms(entry, [Platform.SENSOR])
|
return await hass.config_entries.async_unload_platforms(entry, [Platform.SENSOR])
|
||||||
|
|
||||||
|
|
||||||
async def _async_update_listener(
|
|
||||||
hass: HomeAssistant, entry: ProximityConfigEntry
|
|
||||||
) -> None:
|
|
||||||
"""Handle options update."""
|
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
|
||||||
|
@ -13,7 +13,7 @@ from homeassistant.config_entries import (
|
|||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
OptionsFlow,
|
OptionsFlowWithReload,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_ZONE, UnitOfLength
|
from homeassistant.const import CONF_ZONE, UnitOfLength
|
||||||
from homeassistant.core import State, callback
|
from homeassistant.core import State, callback
|
||||||
@ -87,7 +87,7 @@ class ProximityConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
|
def async_get_options_flow(config_entry: ConfigEntry) -> ProximityOptionsFlow:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return ProximityOptionsFlow()
|
return ProximityOptionsFlow()
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class ProximityConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProximityOptionsFlow(OptionsFlow):
|
class ProximityOptionsFlow(OptionsFlowWithReload):
|
||||||
"""Handle a option flow."""
|
"""Handle a option flow."""
|
||||||
|
|
||||||
def _user_form_schema(self, user_input: dict[str, Any]) -> vol.Schema:
|
def _user_form_schema(self, user_input: dict[str, Any]) -> vol.Schema:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user