Template trigger not firing (blueprint)

Hi everyone,
I’m trying to set up a blueprint automation for some lights. As part of it, I want to trigger every time the lights are toggled. I ask for the lights in the input section and then I have:


mode: single
trigger_variables:
  trigger_source: "other" 
  lights_target: !input the_lights
  light_entities: >
    {% set entities = lights_target.entity_id if lights_target.entity_id is defined else [] %}
    {{ entities }}
trigger:
  - id: toggled_outside
    platform: template
    value_template: >
      {% set lights = variables.light_entities %}
      {% set changed_entity = trigger.to_state.entity_id %}
      {{ changed_entity in lights and (trigger.to_state.state == 'on' or trigger.to_state.state == 'off') }}

This is how the variable looks like:


lights_target:
  entity_id:
    - light.all_lights_hall_lights
light_entities:
  - light.all_lights_hall_lights

At the moment, this isn´t throwing any errors but when I toggle the light the automation won´t trigger. Does anyone have any ideas?
Thanks in advance.

You are calling non-existent variables named variables and trigger.

Instead of using a Target selector, you would be better served using an Entity selector. This would allow you to use the input variable directly in a State trigger, so all selected entities can be monitored.


blueprint:
  input:
    lights:
      name: Lights
      selector:
        entity:
          filter:
            - domain: light
          multiple: true
triggers:
  - trigger: state
    entity_id: !input lights
    to:
      - 'on'
      - 'off'
    from:
      - 'on'
      - 'off'
conditions: []
actions:
....
1 Like

Many thanks!