Skip to content

Commit 2d9a7e8

Browse files
tboyce021fabaff
authored andcommitted
Document icon_template for template sensor (#1991)
1 parent 2b28667 commit 2d9a7e8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

source/_components/sensor.template.markdown

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Configuration variables:
3636
- **friendly_name** (*Optional*): Name to use in the Frontend.
3737
- **unit_of_measurement** (*Optional*): Defines the units of measurement of the sensor, if any.
3838
- **value_template** (*Required*): Defines a [template](/topics/templating/) to extract a value from the event bus.
39+
- **icon_template** (*Optional*): Defines a [template](/topics/templating/) for the icon of the sensor.
3940
- **entity_id** (*Optional*): Add a list of entity IDs so the sensor only reacts to state changes of these entities. This will reduce the number of times the sensor will try to update it's state.
4041
4142
@@ -136,3 +137,18 @@ sensor:
136137
unit_of_measurement: 'kB/s'
137138
```
138139

140+
### {% linkable_title Change the icon %}
141+
142+
This example shows how to change the icon based on the day/night cycle.
143+
144+
```yaml
145+
sensor:
146+
- platform: template
147+
sensors:
148+
day_night:
149+
friendly_name: 'Day/Night'
150+
value_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}Day{% else %}Night{% endif %}'{% endraw %}
151+
icon_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}mdi:weather-sunny{% else %}mdi:weather-night{% endif %}'{% endraw %}
152+
153+
```
154+

0 commit comments

Comments
 (0)