#Event trigger: event_data subkey doesn't take list

1 messages · Page 1 of 1 (latest)

clever pebble
#

Hi there 👋 as far as I understand the event trigger docs, this yaml should work, but it doesn't. The trigger never triggers. If I make seperate triggers for each of the /dw_plus_xx, they work just fine.

  # doesn't work
  - alias: reaction telegram
    trigger: event
    event_type: telegram_callback
    event_data:
      command:
        - "/dw_plus_p1"
        - "/dw_plus_s1"
        - "/dw_plus_t1"
  # doesn't work
  - alias: reaction telegram
    trigger: event
    event_type: telegram_callback
    event_data:
      command:
        - "/dw_plus_p1"
  # does work
  - alias: reaction telegram
    trigger: event
    event_type: telegram_callback
    event_data:
      command: "/dw_plus_p1"

Question: Am I misinterpreting the docs where it says # any of these will match or is this a bug?

storm nest
#

I believe you have to separate each command for multiple triggers (as event_data doesn't support lists/arrays) similar to this:

`automation:

  • alias: reaction telegram
    trigger:
    • platform: event
      event_type: telegram_callback
      event_data:
      command: "/dw_plus_p1"
    • platform: event
      event_type: telegram_callback
      event_data:
      command: "/dw_plus_s1"
    • platform: event
      event_type: telegram_callback
      event_data:
      command: "/dw_plus_t1"`

Your first snippet is like HA is literally looking for:

command: ["/dw_plus_p1", "/dw_plus_s1", "/dw_plus_t1"]

in the event payload, which probably doesn't exist?

wind coral
#

Another option is to use a more general trigger, and use conditions like:

triggers:
  - alias: reaction telegram
    trigger: event
    event_type: telegram_callback
conditions:
- condition: template
  value_template: |
    {{ trigger.event.data.command in 
    ["/dw_plus_p1", "/dw_plus_s1","/dw_plus_t1"] }}
clever pebble
#

Thank you both, that is really kind of you. ❤️ However, my concern is of something else. Please head to the documentation linked above and look at the first two yaml boxes and this quote:
It is also possible to listen for multiple events at once.

next dust
#

But not for the data

solemn ice
#

I was going to say the same, but it also appears to work for context:

      context:
        user_id:
        # any of these will match
          - "MY_USER_ID"
          - "ANOTHER_USER_ID"
#

but not data, which is directly matched

clever pebble
#

okay so this is expected behavior. Very unfortunate, as I was trying to populate it with a list from a trigger_variable, but there's probably a good reason why it is that way. Thank you all!