Newby Rule machine problem

Hi I'm new to Rule machine.
I got everything working so far,
my only problem is right now I'm in the last stage of the rule
The AC/heatpump turns on as it should but it shuts off and on every few minutes.
Last night I had the on commands first but it turned on and off quick every few minutes.
How can I avoid this quick status change ?


I think it would be much easier to read your rule if you posted screenshots of it instead of pasting.
Also, please screenshot the rule trigger as well.

That way it's easier for us to help you.

I can't get the whole rule in a screenshot that's why I copied it.
The trigger is Temperature sensor outside change, that's what someone told me to use what doesn't really make sense to me.

I think the problem is that you haven't quite grasped how the rule is run.
Every time the temperature outside changes even slightly, rule machine goes through each of the steps you wrote, in the order you wrote them.
So each of those if statements will be tested, and each one that is true will send its command. That's why you end up with multiple on and offs.
You really need to rethink this rule, maybe even break it up into more than one.
For starters, doesn't your AC Shop have an internal thermostat that turns itself off if temperature hits the set point?

Why don't you write simple sentences explaining how you want it to work? I think this could help to simplify it, such as:

  • turn on ac every weekday
  • turn off ac between X times
  • if temperature is X, turn off.

Etc

The AC is a heat pump, but they don't work efficiently below 42 degrees ( I have it on 30 for testing)
I don't care about it until 8am before I enter the shop that's why I have it set to 56 when I'm not present.
I can heat with a propane stove when I'm here.
I want it to work at 72 deg when the Office light or the bulb (that I can turn on when I have to run out for a while or on the weekend) is on.
Usually I'm in the shop until 10pm but when I leave earlier and turn the office light off it can go back to night mode.

The AC has a thermostat but I try to avoid changing it at night or run in at 6am to turn it up that's why I have it on a Aeotec Heavy duty switch and set to 75F .

Another thing that you need to realize about RM is that it is triggered for a new process each time a trigger event occurs, such that you can have multiple instances concurrently executing. You have no control over scheduling. Ponder the effects of this carefully.

Then do multiple screenshots. Most of us won’t invest the time to help unless rules and logs are posted as screenshots so that we can easily read them.


To me it looks like all of your IFs are segregated properly, in that each looks like it will only occur under one condition. So each time a temp change occurs only one of the IFs' should run. This is of coarse hard to see from looking at a screenshot. Turning on logging and testing is the only way to be sure.

That being said, some of the IFs inside of day time conditions may get ran multiple times depending how sensitive your Temp sensor is. Remember each time the temp changes it will run through your IFs. So if the temp is 42.0 and then a minute later it drops to 41.9 and then back up to 42 it could cause your Mon thru Fri 8 to 10 AM condition to turn your AC unit on and off multiple times., as an example.

So you probably need to re-think you temp gaps are put something in that will only allow the rule to run every 15 minutes or so.

A Boolean that resets itself every 15 minutes, or whatever time you feel is appropriate, comes to mind.

I understand it runs through all the IF's, but shouldn't it only change a status if an IF meets the set properties ? It looks like by doing that it changes a status for no reason

I've read your rule carefully and I agree that it looks like the conditions are well separated.
In terms of debugging, I would suggest a couple of things:

  1. Inside of your IFs with the times, you use multiple ifs. Why don't you use "ELSE-IFS" instead of "END-IF + New IF"? That could help because then if something already evaluated true, the rule wouldn't need to evaluate the next one.
  2. As suggested above, it's possible that your rule might be triggering too frequently. I suggest you change the trigger from Temperature outside changed to "Periodic Schedule", then have it run at a set interval, for example, every 10 minutes. Might also add a trigger for those lights changing (the ones in the last nested IF that you would like to indicate that you are there).
  3. If you notice this repeated on and off after you make the change suggested about the trigger, please post a screenshot of the logs when that happened so we can see what the issue is.

edit: Just noticed something that could be an issue - You didn't account for the fact of turning off those lights. If the AC was on when you turned off the lights, all your ifs would evaluate to false, so your AC would still be on. I think you have to rethink that.
I would fix it by removing the lights from the outside IFs, and adding to the the first nested IF as an OR condition:
If Temperature of Tri Sensor Shop is >= 75.0 **OR Bulb Office is Off**
Then of course you would have to use Else-ifs for the following ones, so they don't get evaluated as well, and this would presume the lights are on for the following ones, otherwise the first if would be triggered.

I had the Whole rule written with if's and Else if's inside and I thought that was the problem, that's why I eliminated the else if's. I definitely change the trigger to periodic that might help.
I'm still a little confuse with the difference between if, else and else-if.
But I'm fairly new to this, I guess time will teach me :wink:
Thank you so much for all your help, I was always scared of Rule machine, but it's kinda fun, I actually wrote some notification rules (low battery and low temperature) to send messages to my phone. That's really cool

IF checks to see if a condition you define is TRUE

ELSE does what comes after it if the prior condition was FALSE. It does not re-evaluate any conditions. Just does the action following it

ELSE-IF does what follows it if the condition it comes after is FALSE, but not before checking another condition you define.

Do I have to end every else-if with "end if" or do I just end the completed IF with "end if"

Only at the end.

If you want, post the rule again after the changes and we can have a look

You are missing the basic design of Hubitat. The Hub runs on Events to trigger things happening. The trigger event you have defined is whenever the temperature changes, which happens continuously (though, hopefully, not fast). So, you are triggering the Rule continuously. THEN, each time the temperature changes, the Rule runs and starts evaluating your IF statements. The Rule DOES NOT start running when one of the IF conditions is met. Changing to periodic will only trigger the rule periodically.

1 Like

I made some changes it looks like it's working now


you need to fix the time as if exactly 6 it can go into two ifs.
you also need to fix your last if.. i assume you dont want it to go in that case if just one of the ors is true. as written it will

Thanks, I changed to first time zone from 10pm to 5.59am
The last is correct, I can turn the bulb office on with a separate switch it's just a single LED bulb where the light office is a regular light. The idea is: When the light is on I'm present, but when I have to leave just for a while I turn the regular light off, but I can turn the bulb on to keep it warm in the shop while I'm gone.

1 Like