mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Service validation for scene component.
This commit is contained in:
parent
567d1065b2
commit
ad6f5d3b1d
@ -7,9 +7,12 @@ https://home-assistant.io/components/scene/
|
|||||||
import logging
|
import logging
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, SERVICE_TURN_ON, CONF_PLATFORM)
|
ATTR_ENTITY_ID, SERVICE_TURN_ON, CONF_PLATFORM)
|
||||||
from homeassistant.helpers import extract_domain_configs
|
from homeassistant.helpers import extract_domain_configs
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
@ -19,6 +22,10 @@ STATE = 'scening'
|
|||||||
|
|
||||||
CONF_ENTITIES = "entities"
|
CONF_ENTITIES = "entities"
|
||||||
|
|
||||||
|
SCENE_SERVICE_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
})
|
||||||
|
|
||||||
SceneConfig = namedtuple('SceneConfig', ['name', 'states'])
|
SceneConfig = namedtuple('SceneConfig', ['name', 'states'])
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +68,8 @@ def setup(hass, config):
|
|||||||
for scene in target_scenes:
|
for scene in target_scenes:
|
||||||
scene.activate()
|
scene.activate()
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_TURN_ON, handle_scene_service)
|
hass.services.register(DOMAIN, SERVICE_TURN_ON, handle_scene_service,
|
||||||
|
schema=SCENE_SERVICE_SCHEMA)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user