Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105614

entity_id template in wait_for_trigger

$
0
0

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?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>