Add more samples

This commit is contained in:
Fabian Affolter 2016-07-22 10:38:04 +02:00
parent 4ea29a790b
commit 011c8972b3
No known key found for this signature in database
GPG Key ID: DDF3D6F44AAB1336

View File

@ -73,7 +73,7 @@ Home Assistant adds extensions to allow templates to access all of the current s
- `distance()` will measure the distance in meters between home, entity, coordinates.
- `closest()` will find the closest entity.
- `relative_time(timestamp)` will format the date time as relative time vs now (ie 7 seconds)
- `float` will format the output as float.
## {% linkable_title Examples %}
@ -119,7 +119,12 @@ Print out a list of all the sensor states.
{% if states('sensor.temperature') | float > 20 %}
It is warm!
{%endif %}{% endraw %}
{%endif %}
{{ as_timestamp(states.binary_sensor.garage_door.last_changed) }}
{{ as_timestamp(now) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}
{% endraw %}
```
### {% linkable_title Distance examples %}
@ -183,4 +188,11 @@ It depends per component or platform but it is common to be able to define a tem
# Extract third prime number
{% raw %}{{ value_json.primes[2] }}{% endraw %}
# Format output
{% raw %}{{ "%+.1f" | value_json }}{% endraw %}
# Calculations
{% raw %}{{ value_json | multiply(1024) }}{% endraw %}
{% raw %}{{ value_json.used | multiply(0.0001) | round(0) }}{% endraw %}
```