RM 4 - How do I delay off and cancel

Can someone help me figure out why this rule wont turn off lights?

1 Like

Before I get too far, is there a reason you aren't using the stock Motion Lighting app instead? It can do all of this (including the lux check), and it's a lot easier to set up.

Your problem is likely that you're checking different motion sensors in your conditionals than you're using in your triggers. Consider the following sequence of events:

  1. Kitchen 1 and Kitchen 2 both become active, with the latter triggering the rule actions.
  2. The rule actions run; since Kitchen 1 and 2 are active, your IF block (the first part) runs and turns on the lights.
  3. Kitchen 2 goes inactive, but kitchen 1 is still active. The former, again, triggers the rule actions to run.
  4. The rule actions run. The first part of your IF block runs again.
  5. Kitchen 1 goes inactive (and let's say the other sensors have remained inactive).
  6. Your lights stay on, as Kitchen 1 is not a trigger for anything.

Looks like the truth value in the IF and ELSE is true for both so the rule says turn off and also turn on at the same time

1 Like

I am using this to learn RM 4.0 and when I updated to the latest firmware, all of my motion lighting apps stopped working.

I understand what you're getting at but I should be able to use 1 set of motion sensors to trigger the event and then another set ( or the same motion sensors ) as a conditional.

doh! I see that now.

Ha! Looks like one of the batteries died on my motion sensor which was leaving it in an always active states. I also forgot to add that same motion sensor in my last conditional so that was causing my issue. Everything has been updated and I am testing right now.

Thanks for pointing that out. I think I was just looking at the code to long and couldn't see the easy answer.

1 Like

Hehe Iā€™m pleased you got it sorted. I noticed since the last firmware update yesterday one of my contact sensors hasnā€™t come back but I donā€™t think itā€™s battery related; just needs pairing again.
Got to admit I agree with you about using RM4 for this instead of Motion Lighting; you get better control and know exactly what the code does and can fix your own bugs

Yes, but there was a gap in your logic. I provided a specific example of when this would fail. (I'm assuming this is one of the things you mentioned that you figured out later.)

You can't fix a bug if it's in the app, regardless of what the (native) app is--you can only fix your own logic if you missed something. A few stock apps, RM included, have made it out the gate with bugs before. As with Motion Lighting, they are generally fixed quickly. There's certainly nothing wrong with using RM for lighting if you prefer to do so, and it clearly has the possibility to give you more control down the road, so there are advantages; I'm just not sure this is one. :slight_smile:

You really have it out for Rule machine and I honestly don't know why. It's no WebCoRE for sure, but it's getting MUCH better with every release.

I prefer to be able to write my own logic, it just makes more sense to me. I develop automation for work so actually seeing the flow and how things work makes it more enjoyable for me. I consider myself an advanced user of automation and different programming languages so as my hobby I like to actually write my own apps. I've written apps in groovy which I have submitted on the forums here, so RM just seems like a natural fit for me.

As with every new language/app there is a learning curve and potential for error, so this was just one of those things.

I don't. I have a lot of rules. I just see people making things much harder than they need to be for no reason, so I always like to check. :slight_smile: Glad you got this rule figured out, and I'm sure you'll enjoy the power it offers (without needing to write custom code, also a possibility) down the line!

That's not how Else-If works. The else-If only is checked if the If is false. That's why it's an else-if. To get the functionality you are talking about you would use 2 if's.

So, @Keo, that is not your problem here.

Also, what are Kitchen-Day and Kitchen-Night? Are they scenes? Do you realize you are turning them both on every time? You need to use turn on switches by mode or activate scenes per mode in order to do something different depending on the time of day.

Also, why do you have it turning on Kitchen - Day when the rule is checking that illuminance is <100? It can't be daytime if Illuminance is that low.

I have restrictions on the scenes to only allow them to turn on during certain modes.

Actually it certainly can. The sensor is in a place that doesn't get much direct sun light but I've figured out what the setting is when the room needs more light.

Yeah I figured that out with the help of @Townsmcp. I have the actual problem fixed.

Could you at least humor me by saying that it was also what I found? :slight_smile: (If you didn't make such a modification, I'd be shocked if it worked in all cases.)

Could you post the screenshot of the new, corrected rule?

Hi Jill.

I am soooo sorry it took so long for me to respond. I saw the notification and meant to respond sooner but I had family events and just forgot. Here it the screen capture you were asking for.

In the else-if statement I left out one motion sensor which was part of the problem. The other issue was a dead battery in motion sensor 2.

Sorry about the delay.

1 Like