mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 01:06:52 +00:00
Add template documentation for logarithm (#4081)
This commit is contained in:
parent
379de6fb86
commit
118a7f59f4
@ -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)
|
||||
- `float` will format the output as float.
|
||||
- `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 `timestamp_local` will convert an UNIX timestamp to local 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
|
||||
{% raw %}{{ value_json | float * 1024 }}{% endraw %}
|
||||
{% raw %}{{ float(value_json) * (2**10) }}{% endraw %}
|
||||
{% raw %}{{ value_json | log }}{% endraw %}
|
||||
{% raw %}{{ log(1000, 10) }}{% endraw %}
|
||||
|
||||
# Timestamps
|
||||
{% raw %}{{ value_json.tst | timestamp_local }}{% endraw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user