From a9f0ddbb18cc316bc5d3077b367b3f5586a1c025 Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Sun, 20 Oct 2019 23:19:19 +0800 Subject: [PATCH] Added 'availability_template' to all Template Switch platform (#10310) * Added 'availability_template' to all Template Swicth platform * Fixed Syntax and default * Removed optional parameter from example config * Apply suggestions from code review Co-Authored-By: Franck Nijhof --- source/_integrations/switch.template.markdown | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/_integrations/switch.template.markdown b/source/_integrations/switch.template.markdown index d98e57f85eb..050b3f2b16a 100644 --- a/source/_integrations/switch.template.markdown +++ b/source/_integrations/switch.template.markdown @@ -20,6 +20,7 @@ This can simplify the GUI and make it easier to write automations. You can mark To enable Template Switches in your installation, add the following to your `configuration.yaml` file: {% raw %} + ```yaml # Example configuration.yaml entry switch: @@ -36,6 +37,7 @@ switch: data: entity_id: switch.skylight_close ``` + {% endraw %} {% configuration %} @@ -56,6 +58,11 @@ switch: description: Defines a template to set the state of the switch. required: true type: template + availability_template: + description: Defines a template to get the `available` state of the component. If the template returns `true`, the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available`. + required: false + type: template + default: true turn_on: description: Defines an action to run when the switch is turned on. required: true @@ -87,6 +94,7 @@ In this section you find some real-life examples of how to use this switch. This example shows a switch that copies another switch. {% raw %} + ```yaml switch: - platform: template @@ -102,6 +110,7 @@ switch: data: entity_id: switch.source ``` + {% endraw %} ### Toggle Switch @@ -109,6 +118,7 @@ switch: This example shows a switch that takes its state from a sensor and toggles a switch. {% raw %} + ```yaml switch: - platform: template @@ -125,6 +135,7 @@ switch: data: entity_id: switch.blind_toggle ``` + {% endraw %} ### Sensor and Two Switches @@ -133,6 +144,7 @@ This example shows a switch that takes its state from a sensor, and uses two momentary switches to control a device. {% raw %} + ```yaml switch: - platform: template @@ -149,6 +161,7 @@ switch: data: entity_id: switch.skylight_close ``` + {% endraw %} ### Change The Icon @@ -156,6 +169,7 @@ switch: This example shows how to change the icon based on the day/night cycle. {% raw %} + ```yaml switch: - platform: template @@ -177,6 +191,7 @@ switch: mdi:garage {% endif %} ``` + {% endraw %} ### Change The Entity Picture @@ -184,6 +199,7 @@ switch: This example shows how to change the entity picture based on the day/night cycle. {% raw %} + ```yaml switch: - platform: template @@ -205,4 +221,5 @@ switch: /local/garage-closed.png {% endif %} ``` + {% endraw %}