From 75566e26fdc4b74c05b5a96f5972dc8c3cf100cd Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 6 Oct 2026 15:09:17 +0200 Subject: [PATCH] Move prosegur service registration to services module (#184467) Co-authored-by: Claude Opus 5.5 --- homeassistant/components/prosegur/__init__.py | 15 ++++++++++++- homeassistant/components/prosegur/camera.py | 14 ++----------- homeassistant/components/prosegur/services.py | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 homeassistant/components/prosegur/services.py diff --git a/homeassistant/components/prosegur/__init__.py b/homeassistant/components/prosegur/__init__.py index 1fb89f3b3703..ce414bf0551f 100644 --- a/homeassistant/components/prosegur/__init__.py +++ b/homeassistant/components/prosegur/__init__.py @@ -8,7 +8,11 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_COUNTRY, CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady -from homeassistant.helpers import aiohttp_client +from homeassistant.helpers import aiohttp_client, config_validation as cv +from homeassistant.helpers.typing import ConfigType + +from .const import DOMAIN +from .services import async_setup_services PLATFORMS = [Platform.ALARM_CONTROL_PANEL, Platform.CAMERA] @@ -17,6 +21,15 @@ type ProsegurConfigEntry = ConfigEntry[Auth] _LOGGER = logging.getLogger(__name__) +CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) + + +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + """Set up the Prosegur Alarm integration.""" + async_setup_services(hass) + return True + + async def async_setup_entry(hass: HomeAssistant, entry: ProsegurConfigEntry) -> bool: """Set up Prosegur Alarm from a config entry.""" try: diff --git a/homeassistant/components/prosegur/camera.py b/homeassistant/components/prosegur/camera.py index 8b5d81ea7817..8a321b5ad51a 100644 --- a/homeassistant/components/prosegur/camera.py +++ b/homeassistant/components/prosegur/camera.py @@ -11,13 +11,10 @@ from homeassistant.components.camera import Camera from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceInfo -from homeassistant.helpers.entity_platform import ( - AddConfigEntryEntitiesCallback, - async_get_current_platform, -) +from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import ProsegurConfigEntry -from .const import DOMAIN, SERVICE_REQUEST_IMAGE +from .const import DOMAIN _LOGGER = logging.getLogger(__name__) @@ -29,13 +26,6 @@ async def async_setup_entry( ) -> None: """Set up the Prosegur camera platform.""" - platform = async_get_current_platform() - platform.async_register_entity_service( - SERVICE_REQUEST_IMAGE, - None, - "async_request_image", - ) - _installation = await Installation.retrieve( entry.runtime_data, entry.data["contract"] ) diff --git a/homeassistant/components/prosegur/services.py b/homeassistant/components/prosegur/services.py new file mode 100644 index 000000000000..99afa4f22799 --- /dev/null +++ b/homeassistant/components/prosegur/services.py @@ -0,0 +1,21 @@ +"""Services for the Prosegur Alarm integration.""" + +from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN +from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers import service + +from .const import DOMAIN, SERVICE_REQUEST_IMAGE + + +@callback +def async_setup_services(hass: HomeAssistant) -> None: + """Set up the services for the Prosegur Alarm integration.""" + + service.async_register_platform_entity_service( + hass, + DOMAIN, + SERVICE_REQUEST_IMAGE, + entity_domain=CAMERA_DOMAIN, + schema=None, + func="async_request_image", + )