mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Service validation for input_boolean component.
This commit is contained in:
parent
bfdbbbddac
commit
7e0d9bc709
@ -6,8 +6,11 @@ at https://home-assistant.io/components/input_boolean/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_ON)
|
ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_ON)
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
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.util import slugify
|
from homeassistant.util import slugify
|
||||||
@ -22,6 +25,10 @@ CONF_NAME = "name"
|
|||||||
CONF_INITIAL = "initial"
|
CONF_INITIAL = "initial"
|
||||||
CONF_ICON = "icon"
|
CONF_ICON = "icon"
|
||||||
|
|
||||||
|
TOGGLE_SERVICE_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def is_on(hass, entity_id):
|
def is_on(hass, entity_id):
|
||||||
"""Test if input_boolean is True."""
|
"""Test if input_boolean is True."""
|
||||||
@ -75,8 +82,10 @@ def setup(hass, config):
|
|||||||
else:
|
else:
|
||||||
input_b.turn_off()
|
input_b.turn_off()
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_TURN_OFF, toggle_service)
|
hass.services.register(DOMAIN, SERVICE_TURN_OFF, toggle_service,
|
||||||
hass.services.register(DOMAIN, SERVICE_TURN_ON, toggle_service)
|
schema=TOGGLE_SERVICE_SCHEMA)
|
||||||
|
hass.services.register(DOMAIN, SERVICE_TURN_ON, toggle_service,
|
||||||
|
schema=TOGGLE_SERVICE_SCHEMA)
|
||||||
|
|
||||||
component.add_entities(entities)
|
component.add_entities(entities)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user