#Repeat count for number of entities with given label and binary state
1 messages · Page 1 of 1 (latest)
Repeat count for number of entities with given label
Repeat count for number of entities with given label and binary state
You can use a template for it. Something like:
{{ label_entities("Test")
|select('match', '^binary_sensor.')
|select('is_state', 'off')
|list
|count
}}
Hmm, I don't quite follow. This looks a lot like what I have for a group that is doing something similar in an automation as the count fora repeat function.
{{ expand(state_attr('group.dailies', 'entity_id')) | selectattr("state",'eq','on') | list | count | int }}
However, when I change your code to fit the first specific use-case (i.e., change "Test" to "Temporary Tasks" (the label in question) and change 'off' to 'on', it doesn't work.
Here it is working. You can go over it step by step. As starter {{ {{ label_entities("Temporary Tasks") }}
This gives: TemplateSyntaxError: expected token ':', got '}'
Ah, fixed that.
{{ label_entities("Temporary Tasks") }}
This lisits the entities with that label
Oh! It's not enough to full fix, but one issuee is that your above code is looking for a binary_sensor match, but it needs to be an input_boolean match. Strangely, correcting that and adding it in still breaks it though.
Granted, it's not necessary to even listen for that since that label will only ever be placed on input_boolean entities anyway.
Ah, I got it!
{{ label_entities("Temporary Tasks") |select('match', '^input_boolean.') |select('is_state', 'off') |list |count }}