Entity service (#15991)
* Add entity service helper * Use entity service helper * Context
This commit is contained in:
parent
e52ba87af1
commit
b682e48e12
14 changed files with 276 additions and 387 deletions
|
@ -142,6 +142,18 @@ class EntityComponent:
|
|||
return [entity for entity in self.entities
|
||||
if entity.available and entity.entity_id in entity_ids]
|
||||
|
||||
@callback
|
||||
def async_register_entity_service(self, name, schema, func):
|
||||
"""Register an entity service."""
|
||||
async def handle_service(call):
|
||||
"""Handle the service."""
|
||||
await self.hass.helpers.service.entity_service_call(
|
||||
self._platforms.values(), func, call
|
||||
)
|
||||
|
||||
self.hass.services.async_register(
|
||||
self.domain, name, handle_service, schema)
|
||||
|
||||
async def _async_setup_platform(self, platform_type, platform_config,
|
||||
discovery_info=None):
|
||||
"""Set up a platform for this component."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue