Add icon template instructions (#2630)
Propose adding icon template instructions to this and the template binary sensor docs.
This commit is contained in:
parent
e1a59aed04
commit
969ebecc66
1 changed files with 14 additions and 0 deletions
|
@ -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 %}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue