mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 00:36:49 +00:00
Merge pull request #193 from pavoni/add_extra_template_sensor
Add more complex sensor.template example.
This commit is contained in:
commit
06b3bf7b1a
@ -53,5 +53,28 @@ sensor:
|
|||||||
unit_of_measurement: '°'
|
unit_of_measurement: '°'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### {% linkable_title Multi line example with an if test %}
|
||||||
|
|
||||||
|
This example shows a multiple line template with and is test. It looks at a sensing switch and shows on/off in the frontend.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
sensor:
|
||||||
|
platform: template
|
||||||
|
sensors:
|
||||||
|
kettle:
|
||||||
|
friendly_name: 'Kettle'
|
||||||
|
{% raw %}value_template: >-
|
||||||
|
{%- if is_state("switch.kettle", "off") %}
|
||||||
|
off
|
||||||
|
{% elif states.switch.kettle.attributes.kwh < 1000 %}
|
||||||
|
standby
|
||||||
|
{% elif is_state("switch.kettle", "on") %}
|
||||||
|
on
|
||||||
|
{% else %}
|
||||||
|
failed
|
||||||
|
{%- endif %}{% endraw %}
|
||||||
|
|
||||||
|
```
|
||||||
|
(please note the blank line to close the multi-line template)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user