Rule Machine automation issue

I have created the attached automation to lock my service door when it has been closed for 10 minutes. However it will lock after being unlocked for 10 minutes even when the service door is open. What am I missing.

Your conditionals for door closed and unlocked are separated from the locking action by 10 minutes. There is nothing to account for any state changes that may occur during that 10 minutes.

Sounds like something like this would be what you want:

Trigger events: Door closed

Actions:

Wait  for event: elapsed time --> 0:10:00
IF (Door closed) THEN 
  Lock: Door lock 
END-IF 

This will lock the lock ten minutes after the door closes if the door is still open. Re-closing the door will reset this timer (trigger events cancel a wait). Opening alone won't, but that's inconsequential because it's checking for that state before doing anything.

What this won't do is lock if left unlocked for 10 minutes without opening the door. You didn't mention that case, so I left it out. This could be modified to account for that if needed.

1 Like

How about this:

Wait  for event: elapsed time --> 0:10:00
IF (Door open) THEN 
 Wait for event: Door closed 
END-IF 
Lock: Door lock 

Not sure about that: if the door opens during the second Wait, you have two subscriptions to the closed event: that wait and the trigger. The former should cancel the wait and start things over, but the latter might get there first (the behavior/order is not guaranteed as far as I know) and lock the door, which is probably the desired outcome.

But it depends on the triggers. I'm assuming they're the same as mine. I wonder if this wouldn't be easier to think about in the "old" IF/ELSE paradigm. :thinking:

EDIT: Also, I suppose it matters what the OP wants to happen if the door is unlocked while closed but never opens.

1 Like

Thanks bertabcd1234. Your automation suggestion works for me