diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index c70a209a35a..94ba43b8545 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -128,9 +128,12 @@ LIGHT_TURN_ON_SCHEMA = ENTITY_SERVICE_SCHEMA.extend( } ) -LIGHT_TURN_OFF_SCHEMA = ENTITY_SERVICE_SCHEMA.extend( - {ATTR_TRANSITION: VALID_TRANSITION, ATTR_FLASH: vol.In([FLASH_SHORT, FLASH_LONG])} -) + +LIGHT_TURN_OFF_SCHEMA = { + ATTR_TRANSITION: VALID_TRANSITION, + ATTR_FLASH: vol.In([FLASH_SHORT, FLASH_LONG]), +} + LIGHT_TOGGLE_SCHEMA = LIGHT_TURN_ON_SCHEMA diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index 348c2a8616b..aa7459d1d3c 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -10,7 +10,6 @@ from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.config_validation import ( # noqa PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE, - ENTITY_SERVICE_SCHEMA, ) from homeassistant.const import ( STATE_ON, @@ -68,17 +67,9 @@ async def async_setup(hass, config): ) await component.async_setup(config) - component.async_register_entity_service( - SERVICE_TURN_OFF, ENTITY_SERVICE_SCHEMA, "async_turn_off" - ) - - component.async_register_entity_service( - SERVICE_TURN_ON, ENTITY_SERVICE_SCHEMA, "async_turn_on" - ) - - component.async_register_entity_service( - SERVICE_TOGGLE, ENTITY_SERVICE_SCHEMA, "async_toggle" - ) + component.async_register_entity_service(SERVICE_TURN_OFF, {}, "async_turn_off") + component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") + component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle") return True diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index a9237635702..42b19da889e 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -15,6 +15,7 @@ from homeassistant.const import ( from homeassistant.core import callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_per_platform, discovery +from homeassistant.helpers.config_validation import ENTITY_SERVICE_SCHEMA from homeassistant.helpers.service import async_extract_entity_ids from homeassistant.loader import bind_hass, async_get_integration from homeassistant.util import slugify @@ -202,6 +203,8 @@ class EntityComponent: @callback def async_register_entity_service(self, name, schema, func, required_features=None): """Register an entity service.""" + if isinstance(schema, dict): + schema = ENTITY_SERVICE_SCHEMA.extend(schema) async def handle_service(call): """Handle the service."""