What’s wrong with my rule?

Ok what am I missing here? This rule isn’t running.

What I want is, when the front door is unlocked (whether physically or by an automation), and the front door contact sensor is closed, to wait 10 minutes and then lock the door. This rule isn’t working. The door never locks.



What am I missing? Seems so simple.

I'd say you're making the IMHO common mistake of overusing the "required expression" feature. This prevents the rule from triggering if the expression is false, which isn't what you want here for two reasons. First, for the contact sensor, you don't really care whether the door is closed at the moment of triggering; you care about its state 10 minutes later when you want to lock the door. Your rule still needs to trigger when the door unlocks and the sensor is closed (as it probably will be). Second, you have the lock being unlocked as a required expression, so that will be false when the door is in the locked state. This would generally be the case when (or right before) you unlock the door, meaning the rule will not be listening for the trigger (the lock becoming unlocked) at that moment.

To address all of this, I'd just do:

Trigger events: Front Door Lock unlocked and stays that way for 0:10:00

Actions to run:

IF (Front Door Contact is closed) THEN
  Lock: Front Door Lock
END-IF

(Also, you have a 1-minute "stays" trigger and a 1-minute delay in your actions, which I'm ignoring since it sounds like you just want 10 minutes once, and the above should do that.)

Robert - I was going to suggest this below. Are both "equally OK" or is starting from the door lock more efficient/reliable?

This isn't really an efficiency difference, just a "what you want" difference. Mine assumes the countdown starts when the door is unlocked (for 10 minutes), and then it should get locked (regardless of how long it has been closed, as long as it is then). Yours starts the countdown when the door closes and locks it if it's still unlocked at that moment.

They'd have nearly the same outcome aside from timing, so I guess just a matter of what you really want! I just made an assumption and didn't consider the other possibility.

3 Likes

Thanks...I think I just realized a problem w/my approach, actually.

If the door is closed and someone unlocks it and then for some reason doesn't open the door, I don't think to door would lock again until it had been opened. So your approach focusing on the door being unlocked seems to be better.

Thank you. I appreciate the help on this. Secondarily, I use our iPhones combined with HomeKit as our presence sensors for when we come and go from the house. I use a hybrid virtual presence / switch with homebridge / maker api so HomeKit knows when we are home or away. I have automations I. HomeKit to turn these switches off (away) and on (hime) based on each of our locations.

With that being said, I have this rule to handle unlocking the doors when we arrive.

Since the switch is turned on and stays on while someone is home and doesn’t turn off unless someone leaves the house, would this rule interfere with your locking rule above? Just wondering if since it sees someone present if it will keep the lock unlocked?

I can't think of how it would. My rule looks only at the contact sensor state (and doesn't need an event from it). The only thing needed to set it in motion is the door becoming unlocked.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.