Skip to content

Add more complex sensor.template example. #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion source/_components/sensor.template.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ In this section you find some real life examples of how to use this sensor.

### {% linkable_title Sun angle %}

This example shows the sun angle in the frontend.
This example shows the sun angle in the frontend.

```yaml
sensor:
Expand All @@ -53,5 +53,28 @@ sensor:
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)