Add template documentation for logarithm (#4081)

This commit is contained in:
Odin Ugedal 2017-11-28 06:29:08 +01:00 committed by Paulus Schoutsen
parent 379de6fb86
commit 118a7f59f4

View File

@ -78,6 +78,7 @@ Home Assistant adds extensions to allow templates to access all of the current s
- `relative_time(timestamp)` will format the date time as relative time vs now (ie 7 seconds) - `relative_time(timestamp)` will format the date time as relative time vs now (ie 7 seconds)
- `float` will format the output as float. - `float` will format the output as float.
- `strptime(string, format)` will parse a string to a datetime based on a [format][strp-format]. - `strptime(string, format)` will parse a string to a datetime based on a [format][strp-format].
- `log(value, base)` will take the logarithm of the input. When the base is omitted, it defaults to `e` - the natural logarithm. Can also be used as a filter.
- Filter `round(x)` will convert the input to a number and round it to `x` decimals. - Filter `round(x)` will convert the input to a number and round it to `x` decimals.
- Filter `timestamp_local` will convert an UNIX timestamp to local time/data. - Filter `timestamp_local` will convert an UNIX timestamp to local time/data.
- Filter `timestamp_utc` will convert an UNIX timestamp to UTC time/data. - Filter `timestamp_utc` will convert an UNIX timestamp to UTC time/data.
@ -254,6 +255,8 @@ The following overview contains a couple of options to get the needed values:
# Math # Math
{% raw %}{{ value_json | float * 1024 }}{% endraw %} {% raw %}{{ value_json | float * 1024 }}{% endraw %}
{% raw %}{{ float(value_json) * (2**10) }}{% endraw %} {% raw %}{{ float(value_json) * (2**10) }}{% endraw %}
{% raw %}{{ value_json | log }}{% endraw %}
{% raw %}{{ log(1000, 10) }}{% endraw %}
# Timestamps # Timestamps
{% raw %}{{ value_json.tst | timestamp_local }}{% endraw %} {% raw %}{{ value_json.tst | timestamp_local }}{% endraw %}