mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Use OptionsFlowWithReload in enphase_envoy (#149171)
This commit is contained in:
parent
40252763d7
commit
3c70932357
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from pyenphase import Envoy
|
from pyenphase import Envoy
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
@ -47,17 +46,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> b
|
|||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
# Reload entry when it is updated.
|
|
||||||
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|
||||||
"""Reload the config entry when it changed."""
|
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
@ -14,7 +14,7 @@ from homeassistant.config_entries import (
|
|||||||
SOURCE_REAUTH,
|
SOURCE_REAUTH,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
OptionsFlow,
|
OptionsFlowWithReload,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
@ -335,7 +335,7 @@ class EnphaseConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class EnvoyOptionsFlowHandler(OptionsFlow):
|
class EnvoyOptionsFlowHandler(OptionsFlowWithReload):
|
||||||
"""Envoy config flow options handler."""
|
"""Envoy config flow options handler."""
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
|
@ -509,7 +509,7 @@ async def test_coordinator_interface_information(
|
|||||||
# verify first time add of mac to connections is in log
|
# verify first time add of mac to connections is in log
|
||||||
assert "added connection" in caplog.text
|
assert "added connection" in caplog.text
|
||||||
|
|
||||||
# trigger integration reload by changing options
|
# update options and reload
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
config_entry,
|
config_entry,
|
||||||
options={
|
options={
|
||||||
@ -517,6 +517,7 @@ async def test_coordinator_interface_information(
|
|||||||
OPTION_DISABLE_KEEP_ALIVE: True,
|
OPTION_DISABLE_KEEP_ALIVE: True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
assert config_entry.state is ConfigEntryState.LOADED
|
assert config_entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user