From 12b72603b69afdac02882f3441c0d48ad41cf036 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 8 Oct 2026 10:58:31 +0200 Subject: [PATCH] Move person service registration to services module (#184836) Co-authored-by: Claude Opus 5.5 --- homeassistant/components/person/__init__.py | 14 ++---------- homeassistant/components/person/services.py | 24 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 homeassistant/components/person/services.py diff --git a/homeassistant/components/person/__init__.py b/homeassistant/components/person/__init__.py index 5c45993c245d..61343551b293 100644 --- a/homeassistant/components/person/__init__.py +++ b/homeassistant/components/person/__init__.py @@ -43,7 +43,6 @@ from homeassistant.core import ( Event, EventStateChangedData, HomeAssistant, - ServiceCall, State, callback, split_entity_id, @@ -53,7 +52,6 @@ from homeassistant.helpers import ( collection, config_validation as cv, entity_registry as er, - service, ) from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.event import async_track_state_change_event @@ -63,6 +61,7 @@ from homeassistant.helpers.typing import ConfigType, VolDictType from .const import CONF_USER_ID, DATA_PERSON, DOMAIN, PersonEntityStateAttribute from .helpers import filter_yaml_data +from .services import async_setup_services _LOGGER = logging.getLogger(__name__) @@ -483,16 +482,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass.bus.async_listen(EVENT_USER_REMOVED, _handle_user_removed) - async def async_reload_yaml(call: ServiceCall) -> None: - """Reload YAML.""" - conf = await entity_component.async_prepare_reload(skip_reset=True) - await yaml_collection.async_load( - await filter_yaml_data(hass, conf.get(DOMAIN, [])) - ) - - service.async_register_admin_service( - hass, DOMAIN, SERVICE_RELOAD, async_reload_yaml - ) + async_setup_services(hass) return True diff --git a/homeassistant/components/person/services.py b/homeassistant/components/person/services.py new file mode 100644 index 000000000000..241ea441e53a --- /dev/null +++ b/homeassistant/components/person/services.py @@ -0,0 +1,24 @@ +"""Services for the person integration.""" + +from homeassistant.const import SERVICE_RELOAD +from homeassistant.core import HomeAssistant, ServiceCall, callback +from homeassistant.helpers.service import async_register_admin_service + +from .const import DATA_PERSON, DOMAIN +from .helpers import filter_yaml_data + + +async def _async_reload_yaml(call: ServiceCall) -> None: + """Reload YAML.""" + hass = call.hass + data = hass.data[DATA_PERSON] + conf = await data.entity_component.async_prepare_reload(skip_reset=True) + await data.yaml_collection.async_load( + await filter_yaml_data(hass, conf.get(DOMAIN, [])) + ) + + +@callback +def async_setup_services(hass: HomeAssistant) -> None: + """Set up the services for the person integration.""" + async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, _async_reload_yaml)