mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Cleanup RainMachine (#42544)
This commit is contained in:
parent
12da814470
commit
31518937c0
@ -44,6 +44,8 @@ CONF_PROGRAM_ID = "program_id"
|
||||
CONF_SECONDS = "seconds"
|
||||
CONF_ZONE_ID = "zone_id"
|
||||
|
||||
DATA_LISTENER = "listener"
|
||||
|
||||
DEFAULT_ATTRIBUTION = "Data provided by Green Electronics LLC"
|
||||
DEFAULT_ICON = "mdi:water"
|
||||
DEFAULT_SCAN_INTERVAL = timedelta(seconds=60)
|
||||
@ -77,7 +79,7 @@ CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up the RainMachine component."""
|
||||
hass.data[DOMAIN] = {DATA_CLIENT: {}}
|
||||
hass.data[DOMAIN] = {DATA_CLIENT: {}, DATA_LISTENER: {}}
|
||||
return True
|
||||
|
||||
|
||||
@ -213,7 +215,9 @@ async def async_setup_entry(hass, config_entry):
|
||||
]:
|
||||
hass.services.async_register(DOMAIN, service, method, schema=schema)
|
||||
|
||||
config_entry.add_update_listener(async_reload_entry)
|
||||
hass.data[DOMAIN][DATA_LISTENER] = config_entry.add_update_listener(
|
||||
async_reload_entry
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
@ -221,6 +225,8 @@ async def async_setup_entry(hass, config_entry):
|
||||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload an OpenUV config entry."""
|
||||
hass.data[DOMAIN][DATA_CLIENT].pop(config_entry.entry_id)
|
||||
cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(config_entry.entry_id)
|
||||
cancel_listener()
|
||||
|
||||
tasks = [
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, component)
|
||||
|
@ -71,6 +71,7 @@ async def test_options_flow(hass):
|
||||
with patch(
|
||||
"homeassistant.components.rainmachine.async_setup_entry", return_value=True
|
||||
):
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
Loading…
x
Reference in New Issue
Block a user