From 0caab133e683b80a1f4dbad8835ba32ecdab2de8 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Tue, 23 Jul 2019 11:07:13 -0600 Subject: [PATCH] Add area support to automation service schemas (#25403) * Add area support to automation service schemas * Fixed import * Mispelling --- homeassistant/components/automation/__init__.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 0e8bf30ae13..f0011f07561 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -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