From 40d3bdf240ab14182157d75c26210c4096ae60e9 Mon Sep 17 00:00:00 2001 From: Petro31 <35082313+Petro31@users.noreply.github.com> Date: Tue, 25 Oct 2022 13:54:05 -0400 Subject: [PATCH] add new jinja test and filters (#24342) Co-authored-by: Franck Nijhof --- .../_docs/configuration/templating.markdown | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index 98cc60763a8..662a24e3112 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -110,6 +110,16 @@ Print out a list of all the sensor states: {% endraw %} +Entities that are on: + +{% raw %} + +```text +{{ ['light.kitchen', 'light.dinig_room'] | select('is_state', 'on') | list }} +``` + +{% endraw% } + Other state examples: {% raw %} @@ -142,6 +152,9 @@ Other state examples: {{ as_local(states.sensor.time.last_changed) }} {{ states('sensor.expires') | as_datetime }} + +# Make a list of states +{{ ['light.kitchen', 'light.dinig_room'] | map('states') | list }} ``` {% endraw %} @@ -182,6 +195,26 @@ With strings: {% endraw %} +List of friendly names: + +{% raw %} + +```text +{{ ['binary_sensor.garage_door', 'binary_sensor.front_door'] | map('state_attr', 'friendly_name') | list }} +``` + +{% endraw% } + +List of lights that are on with a brightness of 255: + +{% raw %} + +```text +{{ ['light.kitchen', 'light.dinig_room'] | select('is_state', 'on') | select('is_state_attr', 'brightness', 255) | list }} +``` + +{% endraw% } + ### Working with Groups Not supported in [limited templates](#limited-templates).