entity_id template in wait_for_trigger

Hello, I’m trying to create a reusable scene rotation automation. Roughly, when I toggle a rocker lightswitch (shelly) 1x, scene1 turns on, when I toggle the same light switch later 3x (each toggle within 3s span from each), scene3 turns on (Pressing 2x, pausing for 4s and pressing 1x should in the end result in turning on scene1).

I wanted to achieve this by setting up a script that takes the following parameters (fields):

  1. trigger_list (list of triggers that can turn on scenes for a given room)
  2. scene_list (list of scenes that are being triggered by repeatedly pressing triggers from the trigger_list)

I intend to call this generic script from room-specific automations.

I started by first testing various sub-components of the script, and it turns out I am unable to wait for repeated press of the parametrized trigger (entity_id).

Essentially, I need this to work:

wait_for_trigger:
  - trigger: state
    entity_id: {{ trigger_list }}
continue_on_timeout: false
timeout:
  hours: 0
  minutes: 0
  seconds: 3
  milliseconds: 0

Taking aside the fact I’m probably handling lists wrong in entity_ids, I tried that with a single value and it still did not work. I assume that this is because the docs mention various things that can be templatized, but not entity_id. So I tried using wait_for_template, but here comes the trouble. My shelly fires a state_change event (and a shelly.click), but because the toggling value is meaningless to me, I want to react to arbitrary state changes (regardless of the actual value). Wait for template requires me to put in value and if I write something like

wait_for_trigger:
  - value_template: "{{ state('trigger_list ') is defined }}"
    trigger: template
timeout:
  hours: 0
  minutes: 0
  seconds: 3
  milliseconds: 0
continue_on_timeout: false

it stops working completely (as opposed to using hardcoded entity_id).

So, the question I have is, how can I wait for an event from a specific device (passing in the device’s entity_id in a template) within a timeout to then trigger an action?

State triggers do not support templating at all…

The state function expects an entity ID, above you are using a static string "trigger_list "… remove the quote marks to use the variable trigger_list. However, I don’t think that will work at all for a list not do I think it will work as you expect with a single entity ID.

If all the switches post shelly.click events, you may have better luck using an Event trigger instead of continuing down the state-based trigger path.

Thanks for the reply, I feared as much. The thing is I wanted to react to events from multiple different switches/buttons in the room and no all are shelly. I think I’ll need to trigger a custom event and react to it instead.