mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 09:17:06 +00:00
adding icon_template example (#9527)
This commit is contained in:
parent
13e2a2d0d5
commit
f8349115ff
@ -215,3 +215,30 @@ binary_sensor:
|
||||
or is_state('binary_sensor.family_room_144', 'on') }}
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
### {% linkable_title Change the icon when state changes %}
|
||||
|
||||
This example demonstrates how to use `icon_template` to change the entity's
|
||||
icon as its state changes, it evaluates the state of its own sensor and uses a
|
||||
conditional statement to output the appropriate icon.
|
||||
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
sun:
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
sun_up:
|
||||
entity_id:
|
||||
- sun.sun
|
||||
value_template: >-
|
||||
{{ is_state("sun.sun", "above_horizon") }}
|
||||
icon_template: >-
|
||||
{% if is_state("binary_sensor.sun_up", "on") %}
|
||||
mdi:weather-sunset-up
|
||||
{% else %}
|
||||
mdi:weather-sunset-down
|
||||
{% endif %}
|
||||
```
|
||||
{% endraw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user