From b42f9f9e070b427acb296524689c54645473cc7f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 2 Apr 2023 21:37:23 -1000 Subject: [PATCH] Add example of sorting states by entity_id (#26822) --- source/_docs/configuration/templating.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index bfc079b6b93..2e48f0bf1a0 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -150,6 +150,16 @@ Print out a list of all the sensor states: {% endfor %} ``` +Print out a list of all the sensor states sorted by `entity_id`: + +{% raw %} + +```text +{% for state in states.sensor | sort(attribute='entity_id') %} + {{ state.entity_id }}={{ state.state }}, +{% endfor %} +``` + {% endraw %} Entities that are on: