mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Add area support to automation service schemas (#25403)
* Add area support to automation service schemas * Fixed import * Mispelling
This commit is contained in:
parent
e6445a602b
commit
0caab133e6
@ -14,6 +14,7 @@ from homeassistant.core import Context, CoreState
|
|||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import condition, extract_domain_configs, script
|
from homeassistant.helpers import condition, extract_domain_configs, script
|
||||||
import homeassistant.helpers.config_validation as cv
|
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 import ToggleEntity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
@ -85,12 +86,7 @@ PLATFORM_SCHEMA = vol.Schema({
|
|||||||
vol.Required(CONF_ACTION): cv.SCRIPT_SCHEMA,
|
vol.Required(CONF_ACTION): cv.SCRIPT_SCHEMA,
|
||||||
})
|
})
|
||||||
|
|
||||||
SERVICE_SCHEMA = vol.Schema({
|
TRIGGER_SERVICE_SCHEMA = ENTITY_SERVICE_SCHEMA.extend({
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids,
|
|
||||||
})
|
|
||||||
|
|
||||||
TRIGGER_SERVICE_SCHEMA = vol.Schema({
|
|
||||||
vol.Required(ATTR_ENTITY_ID): cv.comp_entity_ids,
|
|
||||||
vol.Optional(ATTR_VARIABLES, default={}): dict,
|
vol.Optional(ATTR_VARIABLES, default={}): dict,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -165,12 +161,12 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN, SERVICE_TOGGLE, toggle_service_handler,
|
DOMAIN, SERVICE_TOGGLE, toggle_service_handler,
|
||||||
schema=SERVICE_SCHEMA)
|
schema=ENTITY_SERVICE_SCHEMA)
|
||||||
|
|
||||||
for service in (SERVICE_TURN_ON, SERVICE_TURN_OFF):
|
for service in (SERVICE_TURN_ON, SERVICE_TURN_OFF):
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
DOMAIN, service, turn_onoff_service_handler,
|
DOMAIN, service, turn_onoff_service_handler,
|
||||||
schema=SERVICE_SCHEMA)
|
schema=ENTITY_SERVICE_SCHEMA)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user