Yes you are right, I found it by my self, and had to realize that this was miss configured. Shame on me.
But my failure was on another side.
I run the automation manualy and in this case he ignored the condition in total.
The trace says that the condition was not running but the action was running.
Is it the normal case, that the conditions are not active at manual autmation run? (run now)
I have a variable defined which value is the result of an condition (True)
variables:
windows: !input windows
windows_are_open: "{{ windows | select('is_state', 'on') | list | count > 0}}"
and use a template condition
conditions:
- "{{ not(windows_are_open) }}"
The trace result is the following:
result: true
entities: []
Step configuration:
'{{ not(windows_are_open) }}'
windows are a collection of window sensors and the condition always say the result is true with both situation (window opened and closed)
I also send the variable value via mesage to my phone (as action) and the value is correct. Only the condition always says true
I can not find my issue.
I am pleased for your help
It seams that the Variable contains a string “True” or “False” and the condition always thinks ok there is a string and a non empty string is always true
After debugging a while i think it is related to the target input.
windows | select('is_state', 'on')
is always empty.
How can i access the entities of a target selector (in this case i use labels) ?
And another thing related to this, how can i test target selectors in the template section of the dev-tools ? There I used label_entities and it worked but it seems working different to the targets selector in a blueprint
Target selectors are more of a specialized tool and, IMO, rarely the right choice for most use cases. You can find an explanation of the target object structure in the following article in the forum Cookbook:
Ok reply to the first question, I use labels because aof flexebility. I often had to replace, move, extend, … devices in my HA setup. So I organized my howl device managment by labels. At the moment this is the state to go with.
I found a little solution (which i will link to below). There is a little variable template block which setts a variabe with all underling entities by a given target selector.
It would be great to get this funcionality as a root method/function of Home Assistant. Something like target_entities() !
So here is the solution code:
variables:
covers_target: !input windows_target
covers: >
{%- set ns = namespace(ret=[]) %}
{%- for key in ['device', 'area', 'entity', 'label'] %}
{%- set items = covers_target.get(key ~ '_id', []) %}
{%- if items %}
{%- set items = [ items ] if items is string else items %}
{%- set items = items if key == 'entity' else items | map(key ~ '_entities') | sum(start=[]) %}
{%- set ns.ret = ns.ret + [ items ] %}
{%- endif %}
{%- endfor %}
{{ ns.ret | sum(start=[]) }}