Unexpected rules result

Disclaimer - I am in the process of learning RM and as such have probably made a mistake.

At this point in my RM learning journey I am only looking for an answer as to why I am getting the results I am getting, I will of course happily and willingly accept any and all suggestions on improving what I have already done.

I have a long hallway leading into our master bathroom. What I am attempting to do with this rule is as follows.
At bedtime when the wife gets out of bed and walks down the hall, the hall motion sensor activates and turns on only 1 of 6 light bulbs (MBathroom3) in the bathroom. I don't want any hall lights (Mhallway1 or 2) to activate. From my testing what I have now accomplishes this.

During the Day and Evening times I want the MHallway motion sensor to turn only Mhalway 1 and 2 and at 90% then when she goes into the bathroom have both the Mshower and MBathroom motion sensors turn on MBathroom lights 1-6 (Mshower sensor is to keep lights on while taking a shower). The reason I am doing this this way is that I want the Hallway lights to go off when no motion is detected, leaving the two bathroom motion sensors to keep the bathroom lights on.
Where my "unexpected" results is that when I set the mode to day and activate only the hallway motion sensor all six of the master bathroom lights go on and none of the two hall lights, however when I change the mode to evening and activate the hallway motion sensor only the hallway 2 lights come on and not the 6 bathroom lights as it should be. So apparently the problem is day related but I have been playing with this for over 5 hours and probably can't see the forest from the trees.

I have a setup for my master bathroom that is similar to this. But, I use Motion Lighting instead of Rule Machine to accomplish it. The way that works is that I have one Motion Lighting instance that handles the lights that go on during Day and Evening, but not Night, and a second instance that handles those that come on also at Night.

I know you're trying to learn RM, but as the author of both Motion Lighting and RM, I'd recommend using Motion Lighting in every situation that it can handle, and only turn to RM for weird situations beyond the scope of Motion Lighting. What you end up with in the rule you posted is fairly complex logic to accomplish something that Motion Lighting does in a much more straight forward way.

Motion Lighting has the features you need, including such things as having a shower motion sensor prevent lights from turning off.

5 Likes

I have a ton of motion lighting rules.. Works great and is super easy to setup..

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

Appreciate the recommendation, I have used motion lighting a lot already but in this instance I felt like I had to start somewhere learning RM, so I don't mean to sound dismissive of your's and @bcopeland suggestion regarding Motion Lighting, but in order to know what I am missing I need help identifying the mistake in this rule that causes the bathroom lights to come on in day mode unexpectedly yet work as expected in the evening and bedtime modes. That way later down the line when those "weird situations" come up I may be better equipped to handle them.

1 Like

My suggestion: Turn on logging in RM, and test. That's the way to figure out what is going on. Even add Log actions to the rule to help illuminate what is going on.

1 Like

Thanks, guess there is nothing glaring in my rules that would indicate why my results are what they are. Being relatively new to Hubitat trying to learn the apps and logs at the same time seems at times a bit overwhelming.

I'm a big believer / espouser of two principles: Crawl Walk Run, and Keep It Simple Stupid.

I don't have any rule as complex as what you're attempting, for whatever that's worth. Too complex for my taste. Perhaps that's a bit of a contradiction, given that RM itself is not a simple thing. But the automations in my home are simple to the extent possible.

3 Likes

I know how to do this in motion lightning, but my logic is if the mfg provides an app why not try to learn it. I have the time, desire and willingness to learn and just needed some help. I didn't know who would respond but when the RM expert did I expected an answer to my question not a deferral to another app. It appears that Hubitat was geared more towards the more knowledgeable user which I am not. Based on yesterdays and todays experience, I am out of here, I tried at least. Consider this thread closed.

I think your problem is in the second IF conditions. Conditions are evaluated left to right, and the evaluation bails out once truth is established. So for the IF that starts Mode is Day OR... that will always be true during Day mode, irrespective of any of the other terms. So whenever motion changes, and its not Bedtime, the lights will come on.

Both sides of that IF-THEN start the same way (Day or Evening), so those terms are meaningless in the overall logic since they apply to both sides of the IF-THEN-ELSE.

Complex logic, need parentheses for the term. ==> Avoid all of this logic by using Motion Lighting instead. It's like brain damage trying to sort something like this out.

2 Likes

Also, you should not be both dimming the light and turning it on. Setting the dim level turns on the light. You can lose all of those Switch On actions that are totally redundant.

Continuing: I don't think you want or need to trigger this from mode changing.

And: You don't need separate terms in the logic for each mode; those can be a single term, like this:

That is equivalent to IF (Mode is Day OR Mode is Evening)

If you look at the display of your rule in your first post above, you can see exactly what the truth of each element is at that moment you open or refresh that page. So you can see the first part of the outer IF-THEN is false, and the first part of the second IF-THEN is true, etc. Each term in the condition show its own truth with (T) or (F), and for the conditions taken together [TRUE] or [FALSE]. Paying attention to these as you vary the state of the motion sensors or mode will reveal what's going to happen when the rule runs.

4 Likes

The advice I gave to someone else in another thread probably applies here.

  1. Rules are free. Use multiple rules if it makes it easier, it doesn't hurt to do this.
  2. I often write separate rules for things like this, test each part separately.
  3. Once you get these separate rules where they work fine, pause them. Don't touch these again except for reference or to fall back on.
  4. Start with a whole new rule and try to blend the separate rules into one. You don't necessarily have to do this, the separate rules are fine, but maybe a bit of clutter.
3 Likes

Alternative approach:

This doesn't include your shower motion, but is intended to show how this should be put together.

3 Likes

You also need to close off your IF THENs with END IFs not sure exactly how you want it to run but the advice above is good. Break it down 1st.

2 Likes

Thanks @neonturbo I appreciated all your support and guidance as I said above I am done asking for help as I have an unrealistic vision of what that looks like. I will not be monitoring this forum any more so if you continue to post you will know why and not think I am being rude and ignoring you.

thanks

There is another approach to this sort of rule that I've used, even simpler:

3 Likes

WOW!

5 Likes

I know.. I've been in shock following this thread.. People bending over backwards trying to help.. I don't understand the response

3 Likes

I don't think you did. The response you got is the go to response we always give to a issue like this. If there is a easier way too do this "please do this", RM is not simple when your new and a app like motion lighting will get most people on that learning curve and get what they want. So it avoids all the early frustration for everyone.
Now in this case what's happened is everyone has jumped at the above, when actually you were after going through all that frustration to learn, that is great! But we will still try to 1st put you off :rofl: just so we know your in it for the long ride!

2 Likes

It's somewhat ironic that in the very same minute that you posted you were out of here because you didn't like the advice you'd been given, I posted a detailed analysis of the rule you posted asking for help on, as to why it didn't work right.

2 Likes