You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/_components/sensor.template.markdown
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ Configuration variables:
36
36
- **friendly_name** (*Optional*): Name to use in the Frontend.
37
37
- **unit_of_measurement** (*Optional*): Defines the units of measurement of the sensor, if any.
38
38
- **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.
39
40
- **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.
40
41
41
42
@@ -136,3 +137,18 @@ sensor:
136
137
unit_of_measurement: 'kB/s'
137
138
```
138
139
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 %}
0 commit comments