The Final solution!
@petro you’re a LEGEND!
blueprint:
name: A Test
description: "A Variable State Test for Target Selector input"
domain: script
input:
lights:
name: Targeted Lights
description: The Lights this Script is Targeted at.
selector:
target:
entity:
domain: light
variables:
lights: !input lights
entities: >
{%- set ns = namespace(ret=[]) %}
{%- for key in ['device_id', 'area_id', 'entity_id'] %}
{%- set items = lights.get(key, []) %}
{%- if items %}
{%- set items = [ items ] if items is string else items %}
{%- set filt = key.split('_') | first %}
{%- set items = items if filt == 'entity' else items | map(filt ~ '_entities') | sum(start=[]) %}
{%- set ns.ret = ns.ret + [ items ] %}
{%- endif %}
{%- endfor %}
{{ ns.ret | sum(start=[]) }}
filtered: "{{ entities | select( 'search' , '^light' ) | select('is_state', 'on') | list }}"
lights_on: "{{ filtered | count > 0 }}"
transition: "{{ iif ( lights_on , 90, 0 ) }}"
sequence:
- service: light.turn_on
data:
transition: "{{ transition }}"
target: !input lights
I think i’m going to cry!