Move prosegur service registration to services module (#184467)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
epenet
2026-10-06 15:09:17 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 13668d4395
commit 75566e26fd
3 changed files with 37 additions and 13 deletions
+14 -1
View File
@@ -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:
+2 -12
View File
@@ -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"]
)
@@ -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",
)