added services.yaml integration for input_boolean (#9519)
* added services.yaml integration to input_boolean * added services integration for input_boolean * removed trailing spaces
This commit is contained in:
parent
b8a03f1283
commit
58cc3a2d7a
2 changed files with 41 additions and 3 deletions
|
@ -6,6 +6,7 @@ at https://home-assistant.io/components/input_boolean/
|
|||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -14,6 +15,7 @@ from homeassistant.const import (
|
|||
SERVICE_TOGGLE, STATE_ON)
|
||||
from homeassistant.loader import bind_hass
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.restore_state import async_get_last_state
|
||||
|
@ -102,12 +104,23 @@ def async_setup(hass, config):
|
|||
if tasks:
|
||||
yield from asyncio.wait(tasks, loop=hass.loop)
|
||||
|
||||
descriptions = yield from hass.async_add_job(
|
||||
load_yaml_config_file, os.path.join(
|
||||
os.path.dirname(__file__), 'services.yaml')
|
||||
)
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_TURN_OFF, async_handler_service, schema=SERVICE_SCHEMA)
|
||||
DOMAIN, SERVICE_TURN_OFF, async_handler_service,
|
||||
descriptions[DOMAIN][SERVICE_TURN_OFF],
|
||||
schema=SERVICE_SCHEMA)
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_TURN_ON, async_handler_service, schema=SERVICE_SCHEMA)
|
||||
DOMAIN, SERVICE_TURN_ON, async_handler_service,
|
||||
descriptions[DOMAIN][SERVICE_TURN_ON],
|
||||
schema=SERVICE_SCHEMA)
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_TOGGLE, async_handler_service, schema=SERVICE_SCHEMA)
|
||||
DOMAIN, SERVICE_TOGGLE, async_handler_service,
|
||||
descriptions[DOMAIN][SERVICE_TOGGLE],
|
||||
schema=SERVICE_SCHEMA)
|
||||
|
||||
yield from component.async_add_entities(entities)
|
||||
return True
|
||||
|
|
|
@ -600,3 +600,28 @@ abode:
|
|||
entity_id:
|
||||
description: Entity id of the quick action to trigger.
|
||||
example: 'binary_sensor.home_quick_action'
|
||||
|
||||
input_boolean:
|
||||
toggle:
|
||||
description: Toggles an input boolean
|
||||
|
||||
fields:
|
||||
entity_id:
|
||||
description: Entity id of the input boolean to toggle
|
||||
example: 'input_boolean.notify_alerts'
|
||||
|
||||
turn_off:
|
||||
description: Turns OFF an input boolean
|
||||
|
||||
fields:
|
||||
entity_id:
|
||||
description: Entity id of the input boolean to turn off
|
||||
example: 'input_boolean.notify_alerts'
|
||||
|
||||
turn_on:
|
||||
description: Turns ON an input boolean
|
||||
|
||||
fields:
|
||||
entity_id:
|
||||
description: Entity id of the input boolean to turn on
|
||||
example: 'input_boolean.notify_alerts'
|
||||
|
|
Loading…
Add table
Reference in a new issue