Rule Machine Rule

trying to make it so that when the door opens first the beep doesnt go off, is this right as its not working correctly?

triggers

Sensor - Front Door active
Front Door Lock changed

rule

Notify iPhone: 'Someone at the front door'
IF (Mode is Night(F) [FALSE]) THEN
Repeat 3 times every 0:00:01 (stopable)
Beep: Siren
END-REP
ELSE-IF (Front Door Lock Simulated open(F) [FALSE]) THEN
Delay 0:01:00
Exit Rule
ELSE
Beep: Siren
END-IF

what kind of sensors as it looks strange.. door sensors are not active. they are open close.
also why are you using front door lock in the trigger and soemthing else in the rule that could be the issue as well.

and why the delay before the exit seems like a noop doesnt have any effect whatsoever another instance of the rule can run regardless if one is already running.

sensor is a Philips hue external one that watches over the front door.

lock is a yale. id like to make so that if the lock is opened first it stops the rule from beeping. However if the sensor is triggered first then it beeps accordingly

doesnt seem likely.. the sensor will alwasy trigger first as it is a motion.. cannot get to the lock without triggering it, unless you mean that it is opened from the inside.

you will need tto have a rule that is triggered by both and cancellable.. ie

it also only beeps for 3 seconds so the likelihood of someone unlocking the door in that time to cancel the beep is negligable and not really worth the effort.

yeah so when we open the door from the inside it stops the rule

again it should be only beeping for 3 seconds but if you insist.

you could try something like this

sorry still want it to beep 3 times if its in night mode but only beep once in any other mode

Your rule is almost there, it has everything it needs, plus a couple things that can be removed. You just need to change to order of things.

Conditional statements like you have in your rule will skip over any sections(IF, ELSE-IF, ELSE) that are false. You know that part.

But what you also need to know is that they will do the actions in the first section that is true and then skip over everything after that, even other sections that have true conditions.

So if the mode is night, and your rule is triggered by anything (lock or sensor) it will do the first section (beep 3 times) and skip everything else.

Swap the first and second sections.. The IF statement should check the lock (and exit if it is locked), then the ELSE-IF should check if the mode is Night (and beep 3 times), followed by the ELSE, as it is now. The rule should work ok that way.

As kahn-hubitat mentioned, the delay before exiting doesn’t do anything functional, and should be removed.

For that matter, since you don’t want anything to happen when you unlock the door, then you can remove the lock changed trigger, and only trigger on the sensor. That way, when you leave the house, it won’t do anything when you unlock the door, and the rule won’t run until you step outside and the sensor sees you. But by that time the lock is unlocked, so the rule will exit.

Give that a try, it should work.

thanks i've given this a re think and come up with this

IF (Front Door Lock Simulated open(F) [FALSE]) THEN
Delay 0:01:00
Exit Rule
ELSE-IF (Mode is Night(F) [FALSE]) THEN
Notify Rob's iPhone: 'Someone at the front door Night Mode'
Repeat 3 times every 0:00:01 (stopable)
Beep: Siren
END-REP
ELSE
Notify Rob's iPhone: 'Someone at the front door Beep'
Beep: Siren
END-IF

seems to work ish ok

Yes, that's much better it should work ok. But you have a delay in there, so I assume you are trying to delay the rule for some reason. I can think of a couple scenarios where you need to stop or delay the rule. But where you have that delay in the rule won’t do anything.

A delay stops the rule from running, and Rule machine sets up a scheduled job to start the rule back up again when the delay is over. So in your rule, when it starts back up again it will then exit the rule. However, while the delay is going, any trigger, such as the motion sensor, will start the rule up again from the top, more or less a second copy or the rule. If that happens in your rule and the lock is open, then it will set up another scheduled job for another delay. If the lock is locked when the trigger happens then it will beep. The delay has no affect on stopping anything caused by another trigger.

Many rules have unwanted things happen if they get triggered again too soon, so the general way to prevent that is to use a variable to make rule exit if it gets triggered too soon.

Suppose you unlock the door and go out on the porch. If you stay there, maybe to look at your cellphone, the motion sensor could go inactive and then trigger again when you move. If the lock is still locked, the rule won’t do anything. But if after you lock the door, the motion sensor triggers again, then it will make it beep. So you want to set it up so once it triggers the first time, it won’t beep until after a certain time has passed, such as 2 minutes.

First, you need to create a local boolean variable and set it to true.
In this sample, I called the variable “dobeep”.

Each time the rule runs when the lock is open, it sets dobeep to false and starts a delay to set it back to true in 2 minutes. And if when the lock is locked, it won’t beep until the delay is over and dobeep is true again. (I'm using the preformatted text option here, it allows you to show indents, but puts in goofy colors.)

IF (Front Door Lock Simulated open(F) [FALSE]) THEN
   Cancel delayed actions
   set dobeep to false
   set dobeep to true —> delayed 0:02:00 (cancelable)
   Exit Rule
ELSE-IF (Variable dobeep = false) then
   Exit Rule
ELSE-IF (Mode is Night(F) [FALSE]) THEN
   Notify Rob's iPhone: 'Someone at the front door Night Mode'
   Repeat 3 times every 0:00:01 
     Beep: Siren
   END-REP
ELSE
  Notify Rob's iPhone: 'Someone at the front door'
  Beep: Siren
END-IF

Using something like this will make sure you can get off the porch after locking the door without making it beep again.

Thank you for the explanation its extremely helpful and I'm almost certain other people will learn from your detailed post too.

I'd set the delay as you mentioned so that the sensor didn't trigger again. Now you've explained, I never realised a shadow copy of the rule would run again. The senor in question once triggered doesn't re arm until a minute is over so hence my thinking on the minute delay. Creating varibles does sound like a much more refined way to run it.

It will take me a few days to alter the rule but I'll report once done!

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