Remove EntityComponent.async_register_legacy_entity_service (#152539)

This commit is contained in:
Erik Montnemery
2025-09-18 20:34:25 +02:00
committed by GitHub
parent 6d3ad3ab9c
commit 5bd39804f1
2 changed files with 1 additions and 81 deletions

View File

@@ -18,11 +18,9 @@ from homeassistant.const import (
)
from homeassistant.core import (
Event,
HassJob,
HassJobType,
HomeAssistant,
ServiceCall,
ServiceResponse,
SupportsResponse,
callback,
)
@@ -31,14 +29,7 @@ from homeassistant.loader import async_get_integration, bind_hass
from homeassistant.setup import async_prepare_setup_platform
from homeassistant.util.hass_dict import HassKey
from . import (
config_validation as cv,
device_registry as dr,
discovery,
entity,
entity_registry as er,
service,
)
from . import device_registry as dr, discovery, entity, entity_registry as er, service
from .entity_platform import EntityPlatform, async_calculate_suggested_object_id
from .typing import ConfigType, DiscoveryInfoType, VolDictType, VolSchemaType
@@ -252,43 +243,6 @@ class EntityComponent[_EntityT: entity.Entity = entity.Entity]:
self.hass, self.entities, service_call, expand_group
)
@callback
def async_register_legacy_entity_service(
self,
name: str,
schema: VolDictType | VolSchemaType,
func: str | Callable[..., Any],
required_features: list[int] | None = None,
supports_response: SupportsResponse = SupportsResponse.NONE,
) -> None:
"""Register an entity service with a legacy response format."""
if isinstance(schema, dict):
schema = cv.make_entity_service_schema(schema)
service_func: str | HassJob[..., Any]
service_func = func if isinstance(func, str) else HassJob(func)
async def handle_service(
call: ServiceCall,
) -> ServiceResponse:
"""Handle the service."""
result = await service.entity_service_call(
self.hass, self._entities, service_func, call, required_features
)
if result:
if len(result) > 1:
raise HomeAssistantError(
"Deprecated service call matched more than one entity"
)
return result.popitem()[1]
return None
self.hass.services.async_register(
self.domain, name, handle_service, schema, supports_response
)
@callback
def async_register_entity_service(
self,