Why isn't this timer firing, and how can I use the trigger name in the payload?

I have this automation that should be activated by any of the timer.sonex timers. I can’t find out why it’s not firing:

alias: Slå av forsterker fem minutter etter at JRMC har stoppet
description: ""
triggers:
  - event_type: timer.finished
    event_data:
      entity_id:
        - timer.sone1
        - timer.sone2
        - timer.sone3
        - timer.sone4
        - timer.sone5
        - timer.sone6
        - timer.sone7
        - timer.sone8
        - timer.sone9
    trigger: event
conditions: []
actions:
  - action: rest_command.girder
    data:
      kommandoklasse: Forsterker
      kommando: 0
      sone: 9
mode: single

Isn’t this correct? Or doesn’t multiple triggers work like this? Also, I would like to have the payload sone in the REST command send the number at the end of the triggering timer. How can I set that up? I’m trying to avoid a bunch of different automations doing the same thing.

You can’t specify multiple values for entity_id.

FWIW, I did the same thing years ago, thought it was a bug, reported it, and was told you can’t do that.

Cannot use multiple entity_id with Event Trigger · Issue #47233 · home-assistant/core

The “event” trigger may have many (list of) event types, but not the entity_id. Anything in the “event trigger” under the “event_data” section must match the actual data content of the “firing” event and specifically for timer events, that data section contains only a single entity_id of a single timer.

I suggest you create multiple Event Triggers, one per timer, and assign each trigger’s id with the timer’s number. You can reference the trigger’s id using trigger.id.

alias: Slå av forsterker fem minutter etter at JRMC har stoppet
description: ""
triggers:
  - id: '1'
    trigger: event
    event_type: timer.finished
    event_data:
      entity_id: timer.sone1
  - id: '2'
    trigger: event
    event_type: timer.finished
    event_data:
      entity_id: timer.sone2
  - id: '3'
    trigger: event
    event_type: timer.finished
    event_data:
      entity_id: timer.sone3
  - id: '4'
    trigger: event
    event_type: timer.finished
    event_data:
      entity_id: timer.sone4
conditions: []
actions:
  - action: rest_command.girder
    data:
      kommandoklasse: Forsterker
      kommando: 0
      sone: "{{ trigger.id }}"
mode: single
1 Like

Thank you very much, that works as your solutions always do! And here I thought it was only me. :smile: Edit: Btw trigger ID is something I can use in another part of the system that will cut down on clutter, never thought about that! Thanks for that too!

Oh, a problem in the other automation where I wanted to cut down on clutter. :grimacing: I need the code to actually start the timer that’s triggered in the automation above, but I can’t seem to crate a working template for the timer name. Here is a shortened version, with only one zone:

alias: Vise at JRMC har stoppet
description: ""
triggers:
  - id: "1"
    trigger: state
    entity_id:
      - media_player.hytteserver_stua
    from: playing
    for:
      hours: 0
      minutes: 0
      seconds: 10
conditions: []
actions:
  - action: rest_command.girder
    data:
      kommandoklasse: JRMC
      kommando: Stoppet
      sone: "{{ trigger.id }}"
    alias: Sende REST-melding til Girder om at JRMC stopper
  - action: timer.start
    data:
      target:
        entity_id: timer.sone{{trigger.id}}
    alias: " Timer start i sonene"
mode: single

The rest command is sent, but the timer “timer.sone1” does not start from this. Can you see what I am doing wrong?

target should be at the same level as action and alias. It should not be nested under data.

  - action: timer.start
    target:
      entity_id: timer.sone{{trigger.id}}
    alias: "Timer start i sonene"
1 Like

So it should. Thank you very much again! :grin: