How to monitor for a condition like X has happened, time starts, Z has not happened since timer started?

Basically I think one of my sensors is on the blink. So I’m trying to alert myself to a door being “unlocked” and then door the lock is in is not subsequently opened.

So I’d like to do:-

Trigger: Door lock unlocked
Condition: Door closed
for: one minute
Action: notify

But of course, at the moment, the “condition” isn’t working because the timer doesn’t start when the door gets unlocked.

Thanks!!

Three automations and a one minute timer.

automation1:
trigger: door unlocked
action: start timer

automation2:
trigger: door opened
action: stop timer

automation 3:
trigger: timer finished
action: notify “door unlocked but not opened within one minute”

It could possibly be done with one automation with three triggers (door unlocked, door opened, timer finished) but this seems simpler.

1 Like
- alias: my door lock thingy
  trigger:
    - platform: state
      entity_id:  sensor.mydoor
      to: 'unlocked'
  condition:
    - condition: state
      entity_id: sensor.mydoor
      state: 'closed'
      for:
        minute: 1
  action:
    - service: notify.notify
      data:
        entity_id: device_tracker.mydevice
        message: "FOO"

All of this is covered in the automation docs, you just need to see what triggers and conditions that you can piece together.

Other way to satisfy need to wait a minute starting at trigger:

- alias: my door lock thingy
  trigger:
    - platform: state
      entity_id:  sensor.mydoor
      to: 'unlocked'
  action:
    - delay: "00:01:00"
    - condition: state
      entity_id: sensor.mydoor
      state: 'closed'
    - service: notify.notify
      data:
        entity_id: device_tracker.mydevice
        message: "FOO"

Thanks, that’s what I was already doing and it doesn’t work

This very much looks like it could work! I will give it a shot.

Thank you

I don’t think either of those will do what you want.

@petro’s first automation will always send the message.

The second one will miss opening the door within the first minute and still send the message.

Second one won’t send the message if the condition isn’t met.

It will:

1. Trigger.
2. Wait a minute.
3. If the door is closed:
     a. Send Message.

Yeah but it is highly possible that a person can unlock the door exit through it and close it before the minute is up. In this case he does not want the message. He is trying to capture false/glitch unlocks.

My solution will only send the message if no one opens door within a minute of it being unlocked. Not just if it is closed after a minute.

Very true. The version I posted is not very “smart”.