How easily a rule can be frustrating when you don't think it through

I was in my kitchen doing something at the island. It was around 3pm and the light was on like it should have been and then it was off. But I was not done in here. I was right below the motion sensor. That should have NEVER turned off like that. UNACCEPTABLE.

So I go to my interface. Check the logs to see if the sensors are responding. They are. Hmm ... Virtual switch was on.
:bulb:
Let's check the rule.
Can you see the problem?


No one to blame but myself.

2 Likes

Strange rule? I'm assuming as soon as it turns on it then is firing again and running a off? Why do you have so many triggers? Surly you don't want it to fire as it turns on or off?

the rule evaluates on the triggers and I wanted it to be persistent, thus the triggers. However, the delayed actions will only cancel between 5 and 7pm along with the lights turning on. There is another rule that will turn on the lights if activity exceeds 10 minutes outside of that window of 5-7. The lights will just turn off because they won't cancel. Rookie mistake.

2 Likes

I am thinking you may want to create a motion aggregation zone for all your motion sensors. Seems it would be more efficient then re-evaluating the rule machine rule on each motion change.

https://docs.hubitat.com/index.php?title=Zone_Motion_Controllers

Edit: Also thanks for sharing mistakes as it definitely helps others to learn. For the sake of newer users hitting this thread in the future it would be great if you shared your corrected rule as well.

3 Likes

I, too am always learning. There's always a better way to set up a rule. Input is welcome. I could have definitely written two rules to cover this, I know. But, here is my corrected rule. I want this rule to be very persistent so that if someone would turn off the light switch, it would turn right back on. I like our house to interact with us. We don't use a dashboard or voice commands, so I also want lights to turn off immediately after the room becomes inactive. I also want the lights to turn off right away if mode changes to quiet time or night if they're on. How did I do?

2 Likes

For all but the simplest rule (or other programming endeavor) I use the free account you can have on Lucid Chart to draw a flowchart. In the free account you are limited in size, but I've always had enough to get the job done.

With a flowchart I'm able to easily see the "whole" picture and make modifications to streamline and/or eliminate unneeded conditions.

I am not associated in Lucid Chart but I've never found a more intuitive graphic program in my life. May not work this way for all.

2 Likes

Haha, yes, that is so true... Just one funny experience/mistake to share.
I have an Iris sensor very close to where I spend time reading, working and study. Suddenly the lights started to turn off when they should not, and I had not seen this behavor before. Starting debugging rules and logs, I could for the life of it, NOT figure out why???
Until the historical motion log was checked...
My better halv had been dusting, and at the same time turned the Iris sensor away from the normal viewing field. Duh... No wonder the sensor did not detect me, and therefor missed motions. Hahaha
Stable light control now, and it was an easy fix... hehe :roll_eyes: :crazy_face: :crazy_face: :crazy_face: :rofl: :slightly_smiling_face:

3 Likes

Right! My domestic engineer comes every other Tuesday. She does the same thing. Moves all of my sensors around. I'm glad that she doesn't know what they're for because I could see her swapping them in rooms just to mess with me. I always set up a phrase on alexa, so that when she tells her thank you, she reassures her that she's the tops. She loves the little messages. I change it whenever I think about it.

2 Likes

Just a follow up. My lights are working as they should. Score!

2 Likes

There are some things that you can do that will make your rule a lot more efficient. First of all, you have the motion sensor being active as a condition twice, this is unnecessary. You can move all of the sub-actions in the second active under the first without a problem.

The second problem is that you have the light that the rule controls being a trigger of the rule. This is unnecessary. Turning the light on should not trigger the rule again. If the sensor goes active and the light turns on, that in turn will trigger the rule again with no real affect taking place. So, I would recommend removing that a s a trigger in the rule.

So, I would recommend that following:

If Motion Active Then
      Cancel delayed actions
      If Time is between x and y  and mode is home and lights is off Then
           Dim light to whatever you want.
Else If motion is inactive or mode is a or b 
     Then turn off lights after delay Cancelable.
End-If

I would also recommend having a longer timeout than 3 seconds. That isn't much time to have between motion triggers to keep a light on.

3 Likes

I always forget about nested if's. I'll have to play with that. Thanks for the suggestion. On the other points, I do not require a longer delay because I have another rule for a virtual switch that actually handles that for me, but I needed a delay of some sort so that the action could be cancelled if it got that far. Also my aeotec takes minutes to reset after motion. So, my adjustment is based on the hardware it's built around and on some other rules that you do not see. I also wanted the lights to be a trigger because I want this rule to be persistent enough that if I turn off a light and the rule is supposed to evaluate to true that it turns back on. I've left this out in testing this rule in the past and found that it was not reacting like I wanted. Adding this in gives me the results that I want. Keep in mind that we do not use dashboards around my house. We do not use voice commands either. My husband refuses. The house is set up to interact with us to keep the HAF at optimal levels.

1 Like

Then why trigger off the motion sensor going inactive? This is one of the reasons why rules end up generating POP errors or taking forever to run. Having multiple triggers at the same time or triggers that don't really do anything does nothing but adds overhead. Having the delay in this rule would eliminate another rule and the virtual switch. And if you are turning on a VS at the same time the sensor goes active, you are going to get a POP error from RM because you'll end up with simultaneous executions of the rule because the VS will turn on and the sensor will be active.

Really? If you manually turn off the lights, you want them to be forces back on? I would hate that. What if you really want the lights off in the room but you are in the room? You are unable to turn off the lights. Plus you do realize that you are going to get double execusion of the rule right? So, if the rule turns the lights off the rule is going to run twice, once when it turns them off and then again when it does nothing.

And let's not forget....you were the one that asked for help with this rule. So, obviously it isn't running the way you want. If it was, why would you ask for help?

I chart mine out using the MS whiteboard app. I can't agree enough about the usefulness of visualizing the execution flow of a rule. :+1:

The big picture for this automation is much larger than I want to take the time to explain or defend. I don't get errors on this rule. Everything runs as it should. You'll just need to accept that.

Yes, this is kitchen/dining. I don't ever really want the lights off in this room unless I'm not in it. If I do, I have a button that pauses these rules and keeps them from turning the lights on or off. Rarely do we use it. My husband likes to mess with me and hit the switch on his way out of the room. Then he proceeds to tell me that my "sparkplugs" suck. (From the WebCoRE days. Taught him a quick lesson.

And no, I posted my mistake as a learning tool for others Ryan. And I posted my corrected rule for input. Not for you to tell me how wrong I am or question my reason for posting it. Thanks for the advice on the nested If's. I always forget about them. Now have a nice day.

1 Like

I'm getting very mixed signals here.

Learning what? I don't understand what lesson you were trying to partake to the rest of the community. I can't see what "mistake" you made that you corrected.

Have a good day Ryan. I'm not going to argue with you.

4 Likes

Can you like this? I can see something like this being useful.

1 Like

https://www.microsoft.com/en-us/p/microsoft-whiteboard/9mspc6mp8fm4?activetab=pivot:overviewtab

I'm not sure what you're asking here. But if you want a link to the app, see above. It works best with a touch screen or better yet an active stylus.

1 Like

Thanks! yes, I wanted to take a peek at the app

I'm new to hubitat (set it up 2 days ago). How do you edit your rules in this text format rather than through the GUI? I find the GUI very limiting as I'm a programmer by trade.