Trigger.entity id not working in automation

Hi All,

This is driving me crazy, I am trying to create an automation that will run if I toggle the light in any room three times, so I created a state trigger that includes all the lights in different rooms, and I want to create a “wait_for” action that will wait for the light in the same room to be toggled two more times, however, the trigger.entity_id is not working for me at all , even though it’s working perfectly in the TTS announcement below and the telegram notification.

Whenever I try to save the automation, I get an error message:
“Message malformed: Entity [object Object] is neither a valid entity ID not a valid UUIT for dictionary values @data[‘entity_id’]”

I also tried to use the below but none worked:

{{trigger.to_state.entity_id}}
{{trigger.to_state.object_id}}

alias: Room_Cleaning (Duplicate)
description: ''
trigger:
  - platform: state
    entity_id:
      - light.master_bedroom_light
      - light.yusuf_bedroom_light
      - light.kitchen_light
      - light.meals_room_light
      - light.living_room_light
      - light.bathroom
condition: []
action:
  - wait_for_trigger:
      - platform: state
        entity_id: {{trigger.entity_id}}
    timeout: '3'
    continue_on_timeout: false
  - wait_for_trigger:
      - platform: state
        entity_id: {{trigger.entity_id}}
    timeout: '3'
    continue_on_timeout: false
  - service: tts.google_translate_say
    data:
      entity_id: media_player.yusuf_bedroom
      message: >-
        Starting cleaning in {{ area_name(trigger.entity_id) }} which is area
        number {{(state_attr('input_text.cleaning_areas',
        'pattern')|from_json)[area_id(trigger.entity_id)]}}
  - service: notify.telegram
    data:
      message: >-
        Starting cleaning in {{ area_name(trigger.entity_id) }} which is area
        number {{(state_attr('input_text.cleaning_areas',    
        'pattern')|from_json)[area_id(trigger.entity_id)]}}
mode: single

Please help

Two issues.

  1. Quote your single line templates.
entity_id: "{{trigger.entity_id}}"
  1. But more importantly, the state trigger entity_id does not support templates. Neither in wait_for_trigger nor the normal automation trigger block.

Oh, that’s a bummer :frowning: but thanks for your reply tom

I will have to think of another way of doing it then

Thanks @tom_l , I ended up using the wait_template instead of wait for a trigger and it worked pefectly.

BTW, is it documented somewhere that wait_fro_trigger and normal automation trigger block don’t support templates for the entity_id?

Thanks

Yes. The link I posted in my last post.

1 Like