From 58cc3a2d7a7fd1654aeeb87db456cd9c48eea61e Mon Sep 17 00:00:00 2001
From: Mahasri Kalavala <skalavala@users.noreply.github.com>
Date: Thu, 21 Sep 2017 10:58:12 -0400
Subject: [PATCH] added services.yaml integration for input_boolean (#9519)

* added services.yaml integration to input_boolean

* added services integration for input_boolean

* removed trailing spaces
---
 homeassistant/components/input_boolean.py | 19 ++++++++++++++---
 homeassistant/components/services.yaml    | 25 +++++++++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/homeassistant/components/input_boolean.py b/homeassistant/components/input_boolean.py
index 3c4efdce175..e60f44e8ea0 100644
--- a/homeassistant/components/input_boolean.py
+++ b/homeassistant/components/input_boolean.py
@@ -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
diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml
index 545a883be8f..865a6c7df58 100644
--- a/homeassistant/components/services.yaml
+++ b/homeassistant/components/services.yaml
@@ -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'
-- 
GitLab