Avoid services unload for Isy994 (#146069)

* Avoid services unload for Isy994

* cleanup
This commit is contained in:
Simone Chemelli 2025-06-02 22:19:10 +03:00 committed by GitHub
parent ecc10e9793
commit bbda1761bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 23 deletions

View File

@ -47,7 +47,7 @@ from .const import (
) )
from .helpers import _categorize_nodes, _categorize_programs from .helpers import _categorize_nodes, _categorize_programs
from .models import IsyConfigEntry, IsyData from .models import IsyConfigEntry, IsyData
from .services import async_setup_services, async_unload_services from .services import async_setup_services
from .util import _async_cleanup_registry_entries from .util import _async_cleanup_registry_entries
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
@ -227,9 +227,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: IsyConfigEntry) -> bool
_LOGGER.debug("ISY Stopping Event Stream and automatic updates") _LOGGER.debug("ISY Stopping Event Stream and automatic updates")
entry.runtime_data.root.websocket.stop() entry.runtime_data.root.websocket.stop()
if not hass.config_entries.async_loaded_entries(DOMAIN):
async_unload_services(hass)
return unload_ok return unload_ok

View File

@ -137,10 +137,6 @@ def async_get_entities(hass: HomeAssistant) -> dict[str, Entity]:
@callback @callback
def async_setup_services(hass: HomeAssistant) -> None: def async_setup_services(hass: HomeAssistant) -> None:
"""Create and register services for the ISY integration.""" """Create and register services for the ISY integration."""
existing_services = hass.services.async_services_for_domain(DOMAIN)
if existing_services and SERVICE_SEND_PROGRAM_COMMAND in existing_services:
# Integration-level services have already been added. Return.
return
async def async_send_program_command_service_handler(service: ServiceCall) -> None: async def async_send_program_command_service_handler(service: ServiceCall) -> None:
"""Handle a send program command service call.""" """Handle a send program command service call."""
@ -230,18 +226,3 @@ def async_setup_services(hass: HomeAssistant) -> None:
schema=cv.make_entity_service_schema(SERVICE_RENAME_NODE_SCHEMA), schema=cv.make_entity_service_schema(SERVICE_RENAME_NODE_SCHEMA),
service_func=_async_rename_node, service_func=_async_rename_node,
) )
@callback
def async_unload_services(hass: HomeAssistant) -> None:
"""Unload services for the ISY integration."""
existing_services = hass.services.async_services_for_domain(DOMAIN)
if not existing_services or SERVICE_SEND_PROGRAM_COMMAND not in existing_services:
return
_LOGGER.debug("Unloading ISY994 Services")
hass.services.async_remove(domain=DOMAIN, service=SERVICE_SEND_PROGRAM_COMMAND)
hass.services.async_remove(domain=DOMAIN, service=SERVICE_SEND_RAW_NODE_COMMAND)
hass.services.async_remove(domain=DOMAIN, service=SERVICE_SEND_NODE_COMMAND)
hass.services.async_remove(domain=DOMAIN, service=SERVICE_GET_ZWAVE_PARAMETER)
hass.services.async_remove(domain=DOMAIN, service=SERVICE_SET_ZWAVE_PARAMETER)