mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Only unload RainMachine services if the last config entry is loaded (#60805)
This commit is contained in:
parent
12cd87d230
commit
344cd0d71f
@ -11,7 +11,7 @@ from regenmaschine.controller import Controller
|
|||||||
from regenmaschine.errors import RainMachineError
|
from regenmaschine.errors import RainMachineError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
CONF_IP_ADDRESS,
|
CONF_IP_ADDRESS,
|
||||||
@ -313,9 +313,14 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
if len(hass.config_entries.async_entries(DOMAIN)) == 1:
|
loaded_entries = [
|
||||||
# If this is the last instance of RainMachine, deregister any services defined
|
entry
|
||||||
# during integration setup:
|
for entry in hass.config_entries.async_entries(DOMAIN)
|
||||||
|
if entry.state == ConfigEntryState.LOADED
|
||||||
|
]
|
||||||
|
if len(loaded_entries) == 1:
|
||||||
|
# If this is the last loaded instance of RainMachine, deregister any services
|
||||||
|
# defined during integration setup:
|
||||||
for service_name in (
|
for service_name in (
|
||||||
SERVICE_NAME_PAUSE_WATERING,
|
SERVICE_NAME_PAUSE_WATERING,
|
||||||
SERVICE_NAME_PUSH_WEATHER_DATA,
|
SERVICE_NAME_PUSH_WEATHER_DATA,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user