Add icon template instructions (#2630)

Propose adding icon template instructions to this and the template binary sensor docs.
This commit is contained in:
rpitera 2017-05-15 03:42:52 -04:00 committed by Fredrik Lindqvist
parent e1a59aed04
commit 969ebecc66

View File

@ -110,4 +110,18 @@ switch:
service: switch.turn_on service: switch.turn_on
entity_id: switch.skylight_close entity_id: switch.skylight_close
``` ```
### {% 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 %}
```