#How to create a time delayed automation from an event that has no state?

33 messages · Page 1 of 1 (latest)

robust hull
#

I have some ring cameras connected with the native Ring integration, and the motion detection just seems to come in as a vanilla event with no "state" or value to check for- just the time that it occurred. Essentially I am trying to make an automation that does something like the following:

  1. turn switch ON when event is received
  2. wait for 10 minutes
    --- if another event is received, restart 10 minute wait
  3. turn switch OFF

I have successfully had it turn ON using the event to trigger the initial action, but I'm unsure how to set the rest up. Many thanks for anyone who has any hints!

#

just figured it out...

"Wait for trigger"

  • timeout 10min
  • continue on timeout enabled
  • trigger: ring motion event
sonic brook
#

Why would you not just:

delay:
  minutes: 10
#

Set the automation mode to "restart" to get your point 2 behaviour

robust hull
#

hmm ok thanks for the tip!

sonic brook
#

np

robust hull
#

hmm, where is the restart option?

sonic brook
#

Under the 3 dots, change mode

robust hull
#

oh, looks like it was already set to that

#

here is the yaml

alias: "Some Lights: Cam Motion > ON"
description: ""
triggers:
  - entity_id:
      - event.REDACTED
    trigger: state
conditions: []
actions:
  - type: turn_on
    device_id: REDACTED
    entity_id: REDACTED
    domain: switch
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - event.REDACTED
    timeout:
      hours: 0
      minutes: 3
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: REDACTED
    entity_id: REDACTED
    domain: switch
mode: restart
#

pretty simple stuff right? hehe, just getting my feet wet 💜

sonic brook
#

does the ring integration give you a "last event" entity with a timestamp?

robust hull
#

I think so, when I add it to the dashboard it shows

  • last changed
  • last updated
#

but it just says "detected an event"

sonic brook
#

ah fair enough

robust hull
#

not sure how to check if there is a last event entity

sonic brook
#

Ah no, doesn't look like it does

robust hull
#

this is working super well though thankfully

#

the timer reset is clutch!

sonic brook
#

always satisfying when you get something like that working 🙂

robust hull
#

yeah, making these cheap and somewhat annoying devices I've had living rent free work together is very satisfying

sonic brook
#

well glad you're making progress on it, soon enough you'll be like: "oooh another sensor I can integrate"

robust hull
#

indeed, I am crossing the event horizon as we speak. there is no turning back

sonic brook
#

Take care, I gotta go have breakfast and get going with my day

robust hull
#

ok so if restart is on, the event will stop the automation and restart it?

#

alright, have a great one!

#

I think my wait for trigger is redundant then

sonic brook
robust hull
#

neat! nice that there are 2 ways to do it

sonic brook
#

yeah you could swap it for just a delay rather than waiting for a trigger

#

oh there are way more than 2 ways of doing it

#

for example: you could have the event set the value of a datetime helper to be X minutes in the future and turn on, and then trigger again when time is that datetime helper's value to reset to off