#Wait for trigger not working

1 messages · Page 1 of 1 (latest)

mystic ledge
#

Hi, I have an automation that waits for a trigger before proceeding. In in the UI I can see it triggered:

#

but in TRACES it shows as TimeOutError:

#

even though the triggering happens 1 second after - well before 10 seconds. What could be causing it to not continue?

full umbra
#

Are you sure last_changed is actually an attribute of that sensor when you check in developer tools > states?

mystic ledge
#

I am 🙂 I can see it change here:

#

in under 10 seconds so I know the blue banner in the UI is correct but it doesn't work and traces shows timeout

#

even if I change the timeout 1 minute - I can force the change of last_change but still it times out

mystic ledge
#

Any idea anyone?

full umbra
#

can you share the yaml of the automation

mystic ledge
#

I've set the timeout lowerto allow the script to actually work until this is resolved

#

everyything. hasbeen working great but only when it times out

final ice
#

Is this possibly a race condition where the last_changed attribute is getting updated before the wait_for_trigger is armed?

#

You might be better off with a wait_for_template and use a template that checks whether that attribute is within the past few seconds

#

If you really want to use the wait_for_trigger you need to arm it before you call the update_last_called action. You’d have to do that with a combination of sequence and parallel groupings, and perhaps a very short delay prior to calling the update_last_called action.

mystic ledge
#

I did:

parallel:
  - action: alexa_media.update_last_called
    data: {}
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - sensor.alexa_last_called
        attribute: last_changed
    continue_on_timeout: true
    timeout:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 500

And it it waits the minute

#

I can see in the UI the change happens about 2 seconds later from running the script so it should work

#

I am having the same issues with the wait for trigger with my lock - it takes a few seconds to go from unlocked to locked but the wait for trigger to turn to locked times out even though I can see it change during the wait time..

full umbra
#

waiting a minute doesn't help if the race is lost

#

try this

#
parallel:
  - sequence:
      - delay: 0.5
      - action: alexa_media.update_last_called
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - sensor.alexa_last_called
        attribute: last_changed
    continue_on_timeout: true
    timeout:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 500