require a single entity id

This commit is contained in:
Jon Maddox
2018-03-07 10:06:27 -05:00
parent d3a1160ac4
commit 3e20874fd2

View File

@@ -43,7 +43,7 @@ SERVICE_SEEK_BY = 'channels_seek_by'
ATTR_SECONDS = 'seconds'
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({
@@ -69,15 +69,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def service_handler(service):
"""Handler for services."""
entity_ids = service.data.get(ATTR_ENTITY_ID)
entity_id = service.data.get(ATTR_ENTITY_ID)
if entity_ids:
devices = [device for device in hass.data[DATA_CHANNELS]
if device.entity_id in entity_ids]
else:
devices = hass.data[DATA_CHANNELS]
device = next([device for device in hass.data[DATA_CHANNELS] if
device.entity_id == entity_id].__iter__(), None)
if device is None:
_LOGGER.warning("Unable to find Channels with entity_id: %s",
str(entity_id))
return
for device in devices:
if service.service == SERVICE_SEEK_FORWARD:
device.seek_forward()
elif service.service == SERVICE_SEEK_BACKWARD: