Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions homeassistant/components/rainmachine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
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)
Expand Down Expand Up @@ -77,7 +79,7 @@

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


Expand Down Expand Up @@ -213,14 +215,18 @@ async def unpause_watering(call):
]:
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


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)
Expand Down
1 change: 1 addition & 0 deletions tests/components/rainmachine/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down