mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 07:17:14 +00:00
Document icon_template for template sensor (#1991)
This commit is contained in:
parent
2b28667652
commit
2d9a7e8b8d
@ -36,6 +36,7 @@ Configuration variables:
|
|||||||
- **friendly_name** (*Optional*): Name to use in the Frontend.
|
- **friendly_name** (*Optional*): Name to use in the Frontend.
|
||||||
- **unit_of_measurement** (*Optional*): Defines the units of measurement of the sensor, if any.
|
- **unit_of_measurement** (*Optional*): Defines the units of measurement of the sensor, if any.
|
||||||
- **value_template** (*Required*): Defines a [template](/topics/templating/) to extract a value from the event bus.
|
- **value_template** (*Required*): Defines a [template](/topics/templating/) to extract a value from the event bus.
|
||||||
|
- **icon_template** (*Optional*): Defines a [template](/topics/templating/) for the icon of the sensor.
|
||||||
- **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.
|
- **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.
|
||||||
|
|
||||||
|
|
||||||
@ -136,3 +137,18 @@ sensor:
|
|||||||
unit_of_measurement: 'kB/s'
|
unit_of_measurement: 'kB/s'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### {% 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…
x
Reference in New Issue
Block a user