Add area support to automation service schemas (#25403)

* Add area support to automation service schemas

* Fixed import

* Mispelling
This commit is contained in:
Aaron Bach 2019-07-23 11:07:13 -06:00 committed by GitHub
parent e6445a602b
commit 0caab133e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ from homeassistant.core import Context, CoreState
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import condition, extract_domain_configs, script
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ENTITY_SERVICE_SCHEMA
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity
@ -85,12 +86,7 @@ PLATFORM_SCHEMA = vol.Schema({
vol.Required(CONF_ACTION): cv.SCRIPT_SCHEMA,
})
SERVICE_SCHEMA = vol.Schema({
vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids,
})
TRIGGER_SERVICE_SCHEMA = vol.Schema({
vol.Required(ATTR_ENTITY_ID): cv.comp_entity_ids,
TRIGGER_SERVICE_SCHEMA = ENTITY_SERVICE_SCHEMA.extend({
vol.Optional(ATTR_VARIABLES, default={}): dict,
})
@ -165,12 +161,12 @@ async def async_setup(hass, config):
hass.services.async_register(
DOMAIN, SERVICE_TOGGLE, toggle_service_handler,
schema=SERVICE_SCHEMA)
schema=ENTITY_SERVICE_SCHEMA)
for service in (SERVICE_TURN_ON, SERVICE_TURN_OFF):
hass.services.async_register(
DOMAIN, service, turn_onoff_service_handler,
schema=SERVICE_SCHEMA)
schema=ENTITY_SERVICE_SCHEMA)
return True