Add icon template instructions (#2629)

Propose adding icon template instructions to this and the template switch docs.
This commit is contained in:
rpitera 2017-05-15 03:47:40 -04:00 committed by Fredrik Lindqvist
parent 969ebecc66
commit 4e7bbfad66

View File

@ -92,3 +92,17 @@ binary_sensor:
- sensor.kitchen_co_status
- sensor.wardrobe_co_status
```
### {% linkable_title Change the icon %}
This example shows how to change the icon based on the day/night cycle.
```yaml
sensor:
- platform: template
sensors:
day_night:
friendly_name: 'Day/Night'
value_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}Day{% else %}Night{% endif %}'{% endraw %}
icon_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}mdi:weather-sunny{% else %}mdi:weather-night{% endif %}'{% endraw %}
```