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:
Andrew Sayre 2019-04-10 11:44:58 -05:00 committed by Paulus Schoutsen
parent fc7a187dd6
commit 7624d0e79f
6 changed files with 84 additions and 79 deletions

View file

@ -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(