Skip to content

Commit 118a7f5

Browse files
odinugeballoob
authored andcommitted
Add template documentation for logarithm (home-assistant#4081)
1 parent 379de6f commit 118a7f5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

source/_docs/configuration/templating.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Home Assistant adds extensions to allow templates to access all of the current s
7878
- `relative_time(timestamp)` will format the date time as relative time vs now (ie 7 seconds)
7979
- `float` will format the output as float.
8080
- `strptime(string, format)` will parse a string to a datetime based on a [format][strp-format].
81+
- `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.
8182
- Filter `round(x)` will convert the input to a number and round it to `x` decimals.
8283
- Filter `timestamp_local` will convert an UNIX timestamp to local time/data.
8384
- 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:
254255
# Math
255256
{% raw %}{{ value_json | float * 1024 }}{% endraw %}
256257
{% raw %}{{ float(value_json) * (2**10) }}{% endraw %}
258+
{% raw %}{{ value_json | log }}{% endraw %}
259+
{% raw %}{{ log(1000, 10) }}{% endraw %}
257260
258261
# Timestamps
259262
{% raw %}{{ value_json.tst | timestamp_local }}{% endraw %}

0 commit comments

Comments
 (0)