You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/_docs/configuration/templating.markdown
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,13 @@ Home Assistant adds extensions to allow templates to access all of the current s
80
80
- `float`will format the output as float.
81
81
- `strptime(string, format)`will parse a string to a datetime based on a [format][strp-format].
82
82
- `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.
83
+
- `sin(value)`will return the sine of the input. Can be used as a filter.
84
+
- `cos(value)`will return the cosine of the input. Can be used as a filter.
85
+
- `tan(value)`will return the tangent of the input. Can be used as a filter.
86
+
- `sqrt(value)`will return the square root of the input. Can be used as a filter.
87
+
- `e`mathematical constant, approximately 2.71828.
88
+
- `pi`mathematical constant, approximately 3.14159.
89
+
- `tau`mathematical constant, approximately 6.28318.
83
90
- Filter `round(x)` will convert the input to a number and round it to `x` decimals.
84
91
- Filter `timestamp_local` will convert an UNIX timestamp to local time/data.
85
92
- Filter `timestamp_utc` will convert an UNIX timestamp to UTC time/data.
@@ -274,6 +281,10 @@ The following overview contains a couple of options to get the needed values:
274
281
{% raw %}{{ float(value_json) * (2**10) }}{% endraw %}
275
282
{% raw %}{{ value_json | log }}{% endraw %}
276
283
{% raw %}{{ log(1000, 10) }}{% endraw %}
284
+
{% raw %}{{ sin(pi / 2) }}{% endraw %}
285
+
{% raw %}{{ cos(tau) }}{% endraw %}
286
+
{% raw %}{{ tan(pi) }}{% endraw %}
287
+
{% raw %}{{ sqrt(e) }}{% endraw %}
277
288
278
289
# Timestamps
279
290
{% raw %}{{ value_json.tst | timestamp_local }}{% endraw %}
0 commit comments