Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/_integrations/switch.template.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -36,6 +37,7 @@ switch:
data:
entity_id: switch.skylight_close
```

{% endraw %}

{% configuration %}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -102,13 +110,15 @@ switch:
data:
entity_id: switch.source
```

{% endraw %}

### Toggle Switch

This example shows a switch that takes its state from a sensor and toggles a switch.

{% raw %}

```yaml
switch:
- platform: template
Expand All @@ -125,6 +135,7 @@ switch:
data:
entity_id: switch.blind_toggle
```

{% endraw %}

### Sensor and Two Switches
Expand All @@ -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
Expand All @@ -149,13 +161,15 @@ switch:
data:
entity_id: switch.skylight_close
```

{% endraw %}

### Change The Icon

This example shows how to change the icon based on the day/night cycle.

{% raw %}

```yaml
switch:
- platform: template
Expand All @@ -177,13 +191,15 @@ switch:
mdi:garage
{% endif %}
```

{% endraw %}

### Change The Entity Picture

This example shows how to change the entity picture based on the day/night cycle.

{% raw %}

```yaml
switch:
- platform: template
Expand All @@ -205,4 +221,5 @@ switch:
/local/garage-closed.png
{% endif %}
```

{% endraw %}