mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Do not remove services when last config entry is unloaded in SABnzbd (#133449)
This commit is contained in:
parent
21c3bf48f9
commit
eae25023e7
@ -8,7 +8,6 @@ from typing import Any
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||||
@ -165,17 +164,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: SabnzbdConfigEntry) -> b
|
|||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: SabnzbdConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: SabnzbdConfigEntry) -> bool:
|
||||||
"""Unload a Sabnzbd config entry."""
|
"""Unload a Sabnzbd config entry."""
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
loaded_entries = [
|
|
||||||
entry
|
|
||||||
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 Sabnzbd, deregister any services
|
|
||||||
# defined during integration setup:
|
|
||||||
for service_name in SERVICES:
|
|
||||||
hass.services.async_remove(DOMAIN, service_name)
|
|
||||||
|
|
||||||
return unload_ok
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
rules:
|
rules:
|
||||||
# Bronze
|
# Bronze
|
||||||
action-setup:
|
action-setup: done
|
||||||
status: todo
|
|
||||||
comment: |
|
|
||||||
Do not remove services when all config entries are removed.
|
|
||||||
appropriate-polling: done
|
appropriate-polling: done
|
||||||
brands: done
|
brands: done
|
||||||
common-modules: done
|
common-modules: done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user