Tying trigger.entity_ID into action repeat loop

HI all,

I have yet annother issue with templating, which I hope you could help me with.

I tried to simplify my script by tying the entity that triggered the automation to govern the subsequent loop, i.e. if any window is open for too long, repeat the sequence until the same window is closed.

However, HA does not accept below code with the following error:

Message malformed: Entity {{ trigger.entity_id }} is neither a valid entity ID nor a valid UUID for dictionary value

action:
  - repeat:
      until:
        - condition: state
          entity_id: "{{ trigger.entity_id }}"
          state: "off"

Based on HA documention, shouldn’t this be correct?
HA doc

Thanks again for helping me.

Martin

Now look at this document: https://www.home-assistant.io/docs/scripts/conditions/#state-condition

Nowhere does it say you can template the entity_id of a state condition.

Templates can only be used where explicitly stated. This is usually only in the data or target keys.

What did you see in the documentation that led you to believe you could template the entity_id option?


Use a Template Condition.

action:
  - repeat:
      until:
        - condition: template 
          value_template: "{{ is_state(trigger.entity_id, 'off') }}"

Much obliged, thank you!

1 Like