Continuing the discussion from Allow for multiple labels/areas in label_entities/area_entities:
using this:
{% set areas = {'person.1':'logeerkamer', "person.2":'library',
'person.3':'voorkamer', "person.4":'dorm' } %}
{% set persons = ["person.1", "person.2","person.3", "person.4"] %}
{% set ns = namespace(occupied = [' ']) %}
{% for present in persons|select('is_state', 'home') %}
{% set ns.occupied = ns.occupied + [areas.get(present)] %}
{% endfor %}
{{['dorm','aanbouw','woongedeelte']|map('floor_areas')|sum(start=[])
|reject('match',ns.occupied|join('|'))
|map('area_entities')|sum(start=[])
|select('in',label_entities('binnenlamp'))
|select('is_state','on')|list|sort}}
makes it possible to map those persons to a room (thank you @hilburn in Discord)
however, there is 1 thing I am not sure to be doing right:
if the reject is empty (so all areas should be mapped) the output of the template is []
if I do Not enter
{% set ns = namespace(occupied = [' '])%}
or set it to [none]
but do as I normally do:
{% set ns = namespace(occupied = [])%}
is this a peculiarity of the reject filter, or why else would this be the case.