mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-16 05:46:52 +00:00
Update sensor.template.markdown (#1509)
This commit is contained in:
parent
97d19293db
commit
6169e1f9ae
@ -13,7 +13,7 @@ ha_iot_class: "Local Push"
|
|||||||
logo: home-assistant.png
|
logo: home-assistant.png
|
||||||
---
|
---
|
||||||
|
|
||||||
The `template` platform supports sensors which breaks out `state_attributes` from other entities.
|
The `template` platform supports sensors which break out `state_attributes` from other entities.
|
||||||
|
|
||||||
To enable Template sensors in your installation, add the following to your `configuration.yaml` file:
|
To enable Template sensors in your installation, add the following to your `configuration.yaml` file:
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ sensor:
|
|||||||
friendly_name: 'Glances'
|
friendly_name: 'Glances'
|
||||||
```
|
```
|
||||||
|
|
||||||
By comparing the details published on the [template](/topics/templating/) page the same can be archived with a different approach:
|
By comparing the details published on the [template](/topics/templating/) page the same can be achieved with a different approach:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
value_template: {% raw %}"{%if states.sensor.ENTITY_ID.state == 'on' %}running{%elif states.switch.ENTITY_ID.state == 'off' %}not running{% endif %}"{% endraw %}
|
value_template: {% raw %}"{%if states.sensor.ENTITY_ID.state == 'on' %}running{%elif states.switch.ENTITY_ID.state == 'off' %}not running{% endif %}"{% endraw %}
|
||||||
@ -91,7 +91,7 @@ The [Binary template sensor](/components/binary_sensor.template/) is the one in
|
|||||||
|
|
||||||
### {% linkable_title Multiline example with an if test %}
|
### {% linkable_title Multiline example with an if test %}
|
||||||
|
|
||||||
This example shows a multiple line template with and if test. It looks at a sensing switch and shows on/off in the frontend.
|
This example shows a multiple line template with an if test. It looks at a sensing switch and shows on/off in the frontend.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
sensor:
|
sensor:
|
||||||
@ -120,7 +120,7 @@ Please note the blank line to close the multi-line template.
|
|||||||
|
|
||||||
### {% linkable_title Change the unit of measurement %}
|
### {% linkable_title Change the unit of measurement %}
|
||||||
|
|
||||||
With a template sensor it's easy to convert given values into others if the unit of measurement don't fit your needs.
|
With a template sensor it's easy to convert given values into others if the unit of measurement doesn't fit your needs.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
sensor:
|
sensor:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user