Make async_extract_entities generic (#78490)
This commit is contained in:
parent
635ed562ee
commit
8300f8234c
2 changed files with 6 additions and 4 deletions
|
@ -186,7 +186,7 @@ class EntityComponent(Generic[_EntityT]):
|
||||||
|
|
||||||
This method must be run in the event loop.
|
This method must be run in the event loop.
|
||||||
"""
|
"""
|
||||||
return await service.async_extract_entities( # type: ignore[return-value]
|
return await service.async_extract_entities(
|
||||||
self.hass, self.entities, service_call, expand_group
|
self.hass, self.entities, service_call, expand_group
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable, Iterable
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from functools import partial, wraps
|
from functools import partial, wraps
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any, TypedDict
|
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar
|
||||||
|
|
||||||
from typing_extensions import TypeGuard
|
from typing_extensions import TypeGuard
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -48,6 +48,8 @@ if TYPE_CHECKING:
|
||||||
from .entity import Entity
|
from .entity import Entity
|
||||||
from .entity_platform import EntityPlatform
|
from .entity_platform import EntityPlatform
|
||||||
|
|
||||||
|
_EntityT = TypeVar("_EntityT", bound=Entity)
|
||||||
|
|
||||||
|
|
||||||
CONF_SERVICE_ENTITY_ID = "entity_id"
|
CONF_SERVICE_ENTITY_ID = "entity_id"
|
||||||
CONF_SERVICE_DATA_TEMPLATE = "data_template"
|
CONF_SERVICE_DATA_TEMPLATE = "data_template"
|
||||||
|
@ -276,10 +278,10 @@ def extract_entity_ids(
|
||||||
@bind_hass
|
@bind_hass
|
||||||
async def async_extract_entities(
|
async def async_extract_entities(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entities: Iterable[Entity],
|
entities: Iterable[_EntityT],
|
||||||
service_call: ServiceCall,
|
service_call: ServiceCall,
|
||||||
expand_group: bool = True,
|
expand_group: bool = True,
|
||||||
) -> list[Entity]:
|
) -> list[_EntityT]:
|
||||||
"""Extract a list of entity objects from a service call.
|
"""Extract a list of entity objects from a service call.
|
||||||
|
|
||||||
Will convert group entity ids to the entity ids it represents.
|
Will convert group entity ids to the entity ids it represents.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue