mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
require a single entity id
This commit is contained in:
@@ -43,7 +43,7 @@ SERVICE_SEEK_BY = 'channels_seek_by'
|
|||||||
ATTR_SECONDS = 'seconds'
|
ATTR_SECONDS = 'seconds'
|
||||||
|
|
||||||
CHANNELS_SCHEMA = vol.Schema({
|
CHANNELS_SCHEMA = vol.Schema({
|
||||||
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Required(ATTR_ENTITY_ID): cv.entity_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
CHANNELS_SEEK_BY_SCHEMA = CHANNELS_SCHEMA.extend({
|
CHANNELS_SEEK_BY_SCHEMA = CHANNELS_SCHEMA.extend({
|
||||||
@@ -69,15 +69,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
def service_handler(service):
|
def service_handler(service):
|
||||||
"""Handler for services."""
|
"""Handler for services."""
|
||||||
entity_ids = service.data.get(ATTR_ENTITY_ID)
|
entity_id = service.data.get(ATTR_ENTITY_ID)
|
||||||
|
|
||||||
if entity_ids:
|
device = next([device for device in hass.data[DATA_CHANNELS] if
|
||||||
devices = [device for device in hass.data[DATA_CHANNELS]
|
device.entity_id == entity_id].__iter__(), None)
|
||||||
if device.entity_id in entity_ids]
|
|
||||||
else:
|
if device is None:
|
||||||
devices = hass.data[DATA_CHANNELS]
|
_LOGGER.warning("Unable to find Channels with entity_id: %s",
|
||||||
|
str(entity_id))
|
||||||
|
return
|
||||||
|
|
||||||
for device in devices:
|
|
||||||
if service.service == SERVICE_SEEK_FORWARD:
|
if service.service == SERVICE_SEEK_FORWARD:
|
||||||
device.seek_forward()
|
device.seek_forward()
|
||||||
elif service.service == SERVICE_SEEK_BACKWARD:
|
elif service.service == SERVICE_SEEK_BACKWARD:
|
||||||
|
Reference in New Issue
Block a user