From 118a7f59f45a83e35a5aa8a1058476e324f8130f Mon Sep 17 00:00:00 2001 From: Odin Ugedal Date: Tue, 28 Nov 2017 06:29:08 +0100 Subject: [PATCH] Add template documentation for logarithm (#4081) --- source/_docs/configuration/templating.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index c02fbb7f2a2..40feade2473 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -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 %}