Entity service (#15991)

* Add entity service helper

* Use entity service helper

* Context
This commit is contained in:
Paulus Schoutsen 2018-08-16 09:50:11 +02:00 committed by GitHub
parent e52ba87af1
commit b682e48e12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 276 additions and 387 deletions

View file

@ -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."""