mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-15 13:26:54 +00:00
Add more complex sensor.template example.
This commit is contained in:
parent
2d47cd7c29
commit
1db6e1fed8
@ -41,7 +41,7 @@ In this section you find some real life examples of how to use this sensor.
|
|||||||
|
|
||||||
### {% linkable_title Sun angle %}
|
### {% linkable_title Sun angle %}
|
||||||
|
|
||||||
This example shows the sun angle in the frontend.
|
This example shows the sun angle in the frontend.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
sensor:
|
sensor:
|
||||||
@ -53,5 +53,27 @@ 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", "standby") or
|
||||||
|
is_state("switch.kettle", "off") %}
|
||||||
|
off
|
||||||
|
{% 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