Check for supported features in media_player services (#22878)
* Add check for supported features * Move logic to service helper * Fix hacked in test for seek * Test for service required features
This commit is contained in:
parent
fc7a187dd6
commit
7624d0e79f
6 changed files with 84 additions and 79 deletions
|
@ -179,13 +179,15 @@ class EntityComponent:
|
|||
if entity.available and entity.entity_id in entity_ids]
|
||||
|
||||
@callback
|
||||
def async_register_entity_service(self, name, schema, func):
|
||||
def async_register_entity_service(self, name, schema, func,
|
||||
required_features=None):
|
||||
"""Register an entity service."""
|
||||
async def handle_service(call):
|
||||
"""Handle the service."""
|
||||
service_name = "{}.{}".format(self.domain, name)
|
||||
await self.hass.helpers.service.entity_service_call(
|
||||
self._platforms.values(), func, call, service_name
|
||||
self._platforms.values(), func, call, service_name,
|
||||
required_features
|
||||
)
|
||||
|
||||
self.hass.services.async_register(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue