From 0c0e24dbbec982ae793af305bca1f17632079570 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 3 Sep 2026 13:25:13 +0200 Subject: [PATCH] Remove unnecessary async def in service registration (#181156) --- homeassistant/components/immich/__init__.py | 2 +- homeassistant/components/immich/services.py | 5 +++-- homeassistant/components/indevolt/__init__.py | 2 +- homeassistant/components/indevolt/services.py | 5 +++-- homeassistant/components/jellyfin/__init__.py | 2 +- homeassistant/components/jellyfin/services.py | 5 +++-- homeassistant/components/miele/__init__.py | 2 +- homeassistant/components/miele/services.py | 4 +++- homeassistant/components/portainer/__init__.py | 2 +- homeassistant/components/portainer/services.py | 3 ++- homeassistant/components/risco/__init__.py | 2 +- homeassistant/components/risco/services.py | 5 +++-- homeassistant/components/tuya/__init__.py | 2 +- homeassistant/components/tuya/services.py | 5 +++-- homeassistant/components/unifi_access/__init__.py | 2 +- homeassistant/components/unifi_access/services.py | 3 ++- homeassistant/components/volvo/__init__.py | 2 +- homeassistant/components/volvo/services.py | 5 +++-- 18 files changed, 34 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/immich/__init__.py b/homeassistant/components/immich/__init__.py index d7b9e7924a40..e02b94f772c9 100644 --- a/homeassistant/components/immich/__init__.py +++ b/homeassistant/components/immich/__init__.py @@ -16,7 +16,7 @@ PLATFORMS: list[Platform] = [Platform.SENSOR, Platform.UPDATE] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up immich integration.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/immich/services.py b/homeassistant/components/immich/services.py index 9ca476a27271..d38b605dc24c 100644 --- a/homeassistant/components/immich/services.py +++ b/homeassistant/components/immich/services.py @@ -6,7 +6,7 @@ from aioimmich.exceptions import ImmichError import voluptuous as vol from homeassistant.components.media_source import async_resolve_media -from homeassistant.core import HomeAssistant, ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ServiceValidationError from homeassistant.helpers import service from homeassistant.helpers.selector import MediaSelector @@ -75,7 +75,8 @@ async def _async_upload_file(service_call: ServiceCall) -> None: ) from ex -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services for immich integration.""" hass.services.async_register( diff --git a/homeassistant/components/indevolt/__init__.py b/homeassistant/components/indevolt/__init__.py index 907819e123fe..63268fdec07e 100644 --- a/homeassistant/components/indevolt/__init__.py +++ b/homeassistant/components/indevolt/__init__.py @@ -61,7 +61,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: IndevoltConfigEntry) -> async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up indevolt services (actions).""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/indevolt/services.py b/homeassistant/components/indevolt/services.py index 105534ac16ac..f94c6da499c5 100644 --- a/homeassistant/components/indevolt/services.py +++ b/homeassistant/components/indevolt/services.py @@ -10,7 +10,7 @@ from indevolt_api import ( ) import voluptuous as vol -from homeassistant.core import HomeAssistant, ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import HomeAssistantError, ServiceValidationError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.service import async_extract_config_entry_ids @@ -36,7 +36,8 @@ RT_ACTION_SERVICE_SCHEMA: Final = vol.Schema( ) -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services for Indevolt integration.""" async def charge(call: ServiceCall) -> None: diff --git a/homeassistant/components/jellyfin/__init__.py b/homeassistant/components/jellyfin/__init__.py index 80425b32862d..7fac11a85dc1 100644 --- a/homeassistant/components/jellyfin/__init__.py +++ b/homeassistant/components/jellyfin/__init__.py @@ -18,7 +18,7 @@ CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Jellyfin component.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/jellyfin/services.py b/homeassistant/components/jellyfin/services.py index eeb9f303cbbd..c45c7e485677 100644 --- a/homeassistant/components/jellyfin/services.py +++ b/homeassistant/components/jellyfin/services.py @@ -10,7 +10,7 @@ from homeassistant.components.media_player import ( DOMAIN as MP_DOMAIN, MediaPlayerEntityFeature, ) -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, service from .const import DOMAIN @@ -38,7 +38,8 @@ def _promote_media_fields(data: dict[str, Any]) -> dict[str, Any]: return data -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services for the Jellyfin component.""" service.async_register_platform_entity_service( diff --git a/homeassistant/components/miele/__init__.py b/homeassistant/components/miele/__init__.py index d4c4cff0028a..7df2ddc06ceb 100644 --- a/homeassistant/components/miele/__init__.py +++ b/homeassistant/components/miele/__init__.py @@ -46,7 +46,7 @@ CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up service actions.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/miele/services.py b/homeassistant/components/miele/services.py index 47d1f035563a..40a8a188d4a7 100644 --- a/homeassistant/components/miele/services.py +++ b/homeassistant/components/miele/services.py @@ -13,6 +13,7 @@ from homeassistant.core import ( ServiceCall, ServiceResponse, SupportsResponse, + callback, ) from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import config_validation as cv, device_registry as dr @@ -213,7 +214,8 @@ async def get_programs(call: ServiceCall) -> ServiceResponse: } -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services.""" hass.services.async_register( diff --git a/homeassistant/components/portainer/__init__.py b/homeassistant/components/portainer/__init__.py index 1322134c9fc1..5b0850935a04 100644 --- a/homeassistant/components/portainer/__init__.py +++ b/homeassistant/components/portainer/__init__.py @@ -145,7 +145,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: PortainerConfigEntry) -> async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Portainer integration.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/portainer/services.py b/homeassistant/components/portainer/services.py index 39efb4d50746..c20316458282 100644 --- a/homeassistant/components/portainer/services.py +++ b/homeassistant/components/portainer/services.py @@ -171,7 +171,8 @@ async def recreate_container(call: ServiceCall) -> None: await coordinator.async_request_refresh() -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services.""" hass.services.async_register( diff --git a/homeassistant/components/risco/__init__.py b/homeassistant/components/risco/__init__.py index beaf5951159a..f0277fddefc8 100644 --- a/homeassistant/components/risco/__init__.py +++ b/homeassistant/components/risco/__init__.py @@ -207,6 +207,6 @@ async def _update_listener(hass: HomeAssistant, entry: RiscoConfigEntry) -> None async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Risco integration services.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/risco/services.py b/homeassistant/components/risco/services.py index dc45511c7b73..dc369d61e65c 100644 --- a/homeassistant/components/risco/services.py +++ b/homeassistant/components/risco/services.py @@ -3,7 +3,7 @@ import voluptuous as vol from homeassistant.const import ATTR_CONFIG_ENTRY_ID, ATTR_TIME -from homeassistant.core import HomeAssistant, ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ServiceValidationError from homeassistant.helpers import config_validation as cv, service from homeassistant.util import dt as dt_util @@ -12,7 +12,8 @@ from .const import DOMAIN, SERVICE_SET_TIME from .models import RiscoConfigEntry -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Create the Risco Services/Actions.""" async def _set_time(service_call: ServiceCall) -> None: diff --git a/homeassistant/components/tuya/__init__.py b/homeassistant/components/tuya/__init__.py index 1dc7709a84a1..c58b255cc31c 100644 --- a/homeassistant/components/tuya/__init__.py +++ b/homeassistant/components/tuya/__init__.py @@ -29,7 +29,7 @@ logging.getLogger("tuya_sharing").setLevel(logging.CRITICAL) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Tuya Services.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/tuya/services.py b/homeassistant/components/tuya/services.py index bef24571c2e5..0a6bfa61968f 100644 --- a/homeassistant/components/tuya/services.py +++ b/homeassistant/components/tuya/services.py @@ -11,7 +11,7 @@ from tuya_sharing import CustomerDevice, Manager import voluptuous as vol from homeassistant.const import ATTR_DEVICE_ID -from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse +from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse, callback from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import device_registry as dr @@ -129,7 +129,8 @@ async def async_set_feeder_meal_plan(call: ServiceCall) -> None: ) -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up Tuya services.""" hass.services.async_register( diff --git a/homeassistant/components/unifi_access/__init__.py b/homeassistant/components/unifi_access/__init__.py index 5c7956eb85b9..571d06ee762c 100644 --- a/homeassistant/components/unifi_access/__init__.py +++ b/homeassistant/components/unifi_access/__init__.py @@ -29,7 +29,7 @@ PLATFORMS: list[Platform] = [ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the UniFi Access integration.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/unifi_access/services.py b/homeassistant/components/unifi_access/services.py index 190eddf0f742..47643a53f8ff 100644 --- a/homeassistant/components/unifi_access/services.py +++ b/homeassistant/components/unifi_access/services.py @@ -64,7 +64,8 @@ def _async_get_target( ) -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services for the UniFi Access integration.""" async def _handle_set_lock_rule(call: ServiceCall) -> None: diff --git a/homeassistant/components/volvo/__init__.py b/homeassistant/components/volvo/__init__.py index 5808641ab767..902936151fae 100644 --- a/homeassistant/components/volvo/__init__.py +++ b/homeassistant/components/volvo/__init__.py @@ -39,7 +39,7 @@ CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up Volvo integration.""" - await async_setup_services(hass) + async_setup_services(hass) return True diff --git a/homeassistant/components/volvo/services.py b/homeassistant/components/volvo/services.py index a3c2b2838bd9..0eaabae11044 100644 --- a/homeassistant/components/volvo/services.py +++ b/homeassistant/components/volvo/services.py @@ -8,7 +8,7 @@ from urllib import parse from httpx import AsyncClient, HTTPError, HTTPStatusError import voluptuous as vol -from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse +from homeassistant.core import HomeAssistant, ServiceCall, SupportsResponse, callback from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import config_validation as cv, service from homeassistant.helpers.httpx_client import get_async_client @@ -53,7 +53,8 @@ _IMAGE_ANGLE_MAP = { } -async def async_setup_services(hass: HomeAssistant) -> None: +@callback +def async_setup_services(hass: HomeAssistant) -> None: """Set up services.""" hass.services.async_register(