Skip to content

Commit 06415a6

Browse files
PhracturedBluefabaff
authored andcommitted
Update icon_template docs for switch template (home-assistant#2735)
* Update icon_template docs for switch template * use {% raw %} and {% endraw %}as requested * typo in raw/endraw
1 parent 6d4129c commit 06415a6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

source/_components/switch.template.markdown

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@ switch:
115115
This example shows how to change the icon based on the day/night cycle.
116116

117117
```yaml
118-
sensor:
118+
switch:
119119
- platform: template
120-
sensors:
121-
day_night:
122-
friendly_name: 'Day/Night'
123-
value_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}Day{% else %}Night{% endif %}'{% endraw %}
124-
icon_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}mdi:weather-sunny{% else %}mdi:weather-night{% endif %}'{% endraw %}
125-
120+
switches:
121+
garage:
122+
value_template: {% raw %}"{{ is_state(cover.garage_door', 'on') }}"{% endraw %}
123+
turn_on:
124+
service: cover.open_cover
125+
entity_id: cover.garage_door
126+
turn_off:
127+
service: cover.close_cover
128+
entity_id: cover.garage_door
129+
icon_template: {% raw %}"{% if is_state('cover.garage_door', 'open') %}mdi:garage-open{% else %}mdi:garage{% endif %}"{% endraw %}
126130
```
127131

0 commit comments

Comments
 (0)