From bc068381df34a69954c1af8d94f754436a51b0a1 Mon Sep 17 00:00:00 2001 From: Vaarlion <59558433+Vaarlion@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:51:55 +0100 Subject: [PATCH] Add doc for new `contains` jinja filter and test (#25890) --- .../_docs/configuration/templating.markdown | 56 ++++++++++++++----- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index 9c4fffd7ec4..b5164732616 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -239,7 +239,7 @@ The same thing can also be expressed as a filter: {% raw %} ```text -{{ expand(['device_tracker.paulus', 'group.child_trackers']) +{{ expand(['device_tracker.paulus', 'group.child_trackers']) | selectattr("attributes.battery", 'defined') | join(', ', attribute="attributes.battery") }} ``` @@ -262,7 +262,7 @@ The same thing can also be expressed as a test: {% raw %} ```text -{{ expand('group.energy_sensors') +{{ expand('group.energy_sensors') | selectattr("state", 'is_number') | join(', ') }} ``` @@ -450,7 +450,7 @@ For example, if you wanted to select a field from `trigger` in an automation bas ```yaml # Is the current time past 10:15? - {{ now() > today_at("10:15") }} + {{ now() > today_at("10:15") }} ``` {% endraw %} @@ -465,8 +465,8 @@ For example, if you wanted to select a field from `trigger` in an automation bas {% raw %} ```yaml - # 77 minutes before current time. - {{ now() - timedelta( hours = 1, minutes = 17 ) }} + # 77 minutes before current time. + {{ now() - timedelta( hours = 1, minutes = 17 ) }} ``` {% endraw %} @@ -476,15 +476,15 @@ For example, if you wanted to select a field from `trigger` in an automation bas {% raw %} ```yaml - # Renders to "00:10:00" - {{ as_timedelta("PT10M") }} + # Renders to "00:10:00" + {{ as_timedelta("PT10M") }} ``` {% endraw %} - Filter `timestamp_local(default)` converts a UNIX timestamp to the ISO format string representation as date/time in your local timezone. If that fails, returns the `default` value, or if omitted raises an error. If a custom string format is needed in the string, use `timestamp_custom` instead. - Filter `timestamp_utc(default)` converts a UNIX timestamp to the ISO format string representation representation as date/time in UTC timezone. If that fails, returns the `default` value, or if omitted raises an error. If a custom string format is needed in the string, use `timestamp_custom` instead. -- Filter `timestamp_custom(format_string, local=True, default)` converts an UNIX timestamp to its string representation based on a custom format, the use of a local timezone is the default. If that fails, returns the `default` value, or if omitted raises an error. Supports the standard [Python time formatting options](https://docs.python.org/3/library/time.html#time.strftime). +- Filter `timestamp_custom(format_string, local=True, default)` converts an UNIX timestamp to its string representation based on a custom format, the use of a local timezone is the default. If that fails, returns the `default` value, or if omitted raises an error. Supports the standard [Python time formatting options](https://docs.python.org/3/library/time.html#time.strftime).