mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
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 <frenck@frenck.nl>
This commit is contained in:
parent
ccc7b2de30
commit
a9f0ddbb18
@ -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:
|
To enable Template Switches in your installation, add the following to your `configuration.yaml` file:
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
switch:
|
switch:
|
||||||
@ -36,6 +37,7 @@ switch:
|
|||||||
data:
|
data:
|
||||||
entity_id: switch.skylight_close
|
entity_id: switch.skylight_close
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
@ -56,6 +58,11 @@ switch:
|
|||||||
description: Defines a template to set the state of the switch.
|
description: Defines a template to set the state of the switch.
|
||||||
required: true
|
required: true
|
||||||
type: template
|
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:
|
turn_on:
|
||||||
description: Defines an action to run when the switch is turned on.
|
description: Defines an action to run when the switch is turned on.
|
||||||
required: true
|
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.
|
This example shows a switch that copies another switch.
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
@ -102,6 +110,7 @@ switch:
|
|||||||
data:
|
data:
|
||||||
entity_id: switch.source
|
entity_id: switch.source
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
### Toggle Switch
|
### Toggle Switch
|
||||||
@ -109,6 +118,7 @@ switch:
|
|||||||
This example shows a switch that takes its state from a sensor and toggles a switch.
|
This example shows a switch that takes its state from a sensor and toggles a switch.
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
@ -125,6 +135,7 @@ switch:
|
|||||||
data:
|
data:
|
||||||
entity_id: switch.blind_toggle
|
entity_id: switch.blind_toggle
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
### Sensor and Two Switches
|
### 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.
|
momentary switches to control a device.
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
@ -149,6 +161,7 @@ switch:
|
|||||||
data:
|
data:
|
||||||
entity_id: switch.skylight_close
|
entity_id: switch.skylight_close
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
### Change The Icon
|
### Change The Icon
|
||||||
@ -156,6 +169,7 @@ switch:
|
|||||||
This example shows how to change the icon based on the day/night cycle.
|
This example shows how to change the icon based on the day/night cycle.
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
@ -177,6 +191,7 @@ switch:
|
|||||||
mdi:garage
|
mdi:garage
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
### Change The Entity Picture
|
### Change The Entity Picture
|
||||||
@ -184,6 +199,7 @@ switch:
|
|||||||
This example shows how to change the entity picture based on the day/night cycle.
|
This example shows how to change the entity picture based on the day/night cycle.
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
@ -205,4 +221,5 @@ switch:
|
|||||||
/local/garage-closed.png
|
/local/garage-closed.png
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user