Why's this rule running?

What do i have wrong with this rule? I don't want it to run unless In sleep or Night Mode but it's running in every mode.

IF (Sidewalk Motion Sensor active(F) OR
Lights in motion closed(F) AND
Mode in Night, Sleep(F) [FALSE]) THEN
IF (Private Boolean is true TRUE) On: Front Light
Set Private Boolean False
Cancel Delayed Actions
ELSE
Delay 0:01:00 (cancel)
Off: Front Light
Set Private Boolean True
END-IF

I think it's because you have the Mode restriction only on one side of the OR evaluation. Either add AND Mode: Night,Sleep to both sides or nest the whole thing in a If MODE: Night, Sleep conditional.

1 Like

What do you have for your trigger for the rule?

Also, the Else is going to catch EVERYTHING when the if is Flase, which it is right now because its day mode. What you want is:

If MODE NIGHT
       IF Motion Active or Contact Closed
               Cancel Delay
        Else
              Delay 1 min with Cancel
              off light
        End-if
End-if

Also, the way you are using Private boolean, you will only ever get one delay for motion being active. Then it will ALWAYS turn off after a minute. Because PB will be false so you'll hit the ELSE statement. I would leave the PB out if you don't have a specific use for it.

2 Likes

Hi Ryan, I'm using
Select Trigger Events (ANY will trigger)
Sidewalk Motion Sensor changed
Lights in motion changed

I use the Private boolean because I just took an example from [[Released] Rule 4.0]
And it seems to work fine as far as I know meaning it keeps the lights on for as long there's motion or whatever else. Like If I leave a door open the light's stay on for as long as the door stays open kind of thing.

Lol I should read better
If we don't want the actions to run unless there was a change, the equivalent of change in rule truth of a 3.0 Rule, we can do that explicitly using Private Boolean. In the example above, if one of the two motion sensors went inactive, and then became active again before the lights turned off, the actions would run again, turning the lights on again. Generally, this is harmless. If we want to prevent that redundant action, here is how that is done:
I guess the lights are staying on for that Rule because the door is still open. Love trying to figure out RM4.0

No, you don't need private boolean at all. Set it up the way I showed you above. You need a nested if statement to keep it only happening at night.

1 Like

Could he just do a simpler condition statement with a sub expression:

If MODE NIGHT and
(Motion Active OR Contact Closed)
On: Front Light
Cancel Delay
Else
Delay 1 min with cancel
Off: Front Light
End-If

3 Likes

Ok so it looks like I have And & then's that I shouldn't have but can't figure out if I'm actually writing this correctly.
Triggers:
Lights in motion changed
Sidewalk Motion Sensor changed

Select Actions for Front lights motion
IF (Mode in Night, Sleep(F) AND
Sidewalk Motion Sensor active(F) OR
Lights in motion closed(F) [FALSE]) THEN
On: Front Light
Cancel Delayed Actions
ELSE
Delay 0:01:00 (cancel)
Off: Front Light
END-IF

Well I guess I'm not because I get an error
app:8912019-08-27 06:29:58.971 pm errorjava.util.NoSuchElementException: Cannot pop() an empty List on line 5607 (delayedActsCancel)
I guess the question I should be asking is how do you create Nested if Statements?

Your missing the parentheses around the two conditions and the OR statement.

1 Like

Lol I'm definitely missing something how would I even go about adding Parentheses. I've read though Rule 4.0 Post a few times now and just just can't get this rule to work correctly. It's crazu this isn't even complicated rule but I'm missing something

IIRC, I believe you have to add a Sub Condition.

Yes if I write the rule this way it works great. But if I go and try to write the rule like

I can't figure it out. I needed a nested If statement.
The IF night Mode always gets a then after it. just can't seem to make like he show's how to do it.

The only condition you want in your first statement is night mode. Then Select conditional action action and then If and build another below it just like you did the top one.

Okay No matter what I try I can't get just night mode without a then after it. I get the concept I just can't make it happen. Thank you guys for all your help I'm just having a brain Fart or something

Ok...so you set up your conditional action like this:

Then you click done. and you get this:

Then you click done again....and you get this:

Okay Great At least I know I'm supposed to have the Then. I was going nuts thanks for the walk through that's what I've been doing going to see if this works or a get that error again. Thank you so much for your time

1 Like

Just go slow and follow each stop...make sure your screen matches my screenshot. And remember, you have to always hit done. Forget your browser even has a back or forward button.

I’m not a big fan of nested conditions. It’s just my preference.

1 Like

Wow This is crazy. This is how I wrote the rule since the first time you showed me how to do it hr's ago. Is this correct? I'm not getting the error yet. Maybe when I rebooted for the Update that rolled out today it helped something.
Wow sorry about the Gigantic screen shot forgot about that second monitor

1 Like

Put your cancel delayed actions before you turn on the light and you'll be all set.

1 Like