Rule Machine Trigger Rule Device - How To Make Report

I am writing a rule to trigger a heater to turn on and off in my family room while someone is in the room, watching TV, and the temperature is below a certain degrees. I have written the attached rule and it works perfectly to turn the heater on as soon as you turn on the TV (if the lower temp setting is met) and will turn off if the desired temp is reached or all people leave the room.

The problem I have is the plug must report the power reading again to trigger the rule again if the temp drops low once the rule has finished its initial run. The plug does not report frequently so it can get cold and be that way a while before the heater turns on again. I swapped the TV Plug power reading to a required expression and moved the temp sensor down as the trigger but then you have a similar issue. If I do this then when someone goes in and turns the TV on it must wait for the temp sensor to log a temp change before it turns the heater on resulting in possible setting in the cold for several minutes.

@bravenel or anyone else do you any suggestions on how to improve this rule so that it will trigger when the TV comes on then you don't have to sit and wait forever after the rule is finished running for the heater to turn back on after the temp drops? If there is a way to incorporate another rule into this one to force the trigger event to trigger again (if it is the TV plug or the temp sensor) I am open to that as well.

I appreciate the help as I am wracking my brain on this one. Below is my rule as currently constructed. Ignore the temp settings those are just for trial purposes.

Edit: last line of rule has been corrected. It was correct when I was running the rule but tinkering I pasted the wrong line before posting.

One thing that jumped out at me is the last line - I'm guessing you want that to set PB = True (since the first action was to set it False).

1 Like

Yes you are correct. I have been tinkering with it for so long and changing so much I have accidentally copied in the wrong one. Thank you for pointing that out I will change that. It was correct when I was running the rule.

The problem after that though is the rule won't trigger again until the plug logs a power change. That can take a while.

Overall, I think the rule build looks solid -- this sounds like it's more of an issue with device-level reporting... I'm not sure how much (if any) of that you can overcome with a rule.

1 Like

That is what I was afraid of. I was hoping there was a way to write another rule to force the logging or rerunning of the trigger in this rule somehow or a way to capture the power reading and feed it back into this rule to activate the trigger.

1 Like

My initial sense is to break this into four small rules - Basically an "On/Off TV Rule" and Separate "On/Off Heater Rule" - Use the PBs AND the TV state in the required expressions.

Then make the triggers the heater rule, temperature change (Cold for "ON", Warm for "Off") or the Presense Sensor - As those are the things that are likely to change, and the heater action your doing, ultimately drives temperature as an controlled variable.

Bottom line, I like small quick rules, that set state (either Hub Variables, virtual switches), to avoid delays or waits in rules, and just let small logic changes drive a state machine.

If the temp sensor is very slow to respond, then keep a separate state/boolean for it as well (Temp_Cold = On/Off) driven by a seperate set of temp rules and triggers.
Basically, your saving state in the hub (VSwitches, HubVariables), and not relying on triggers to re-occur

Let me know if the above makes sense, or if your interested I could mock up some pseudo-code for the these 4 small rules. (TV on/off - Driven by power sensor, and Heater on/off - Driven by temp and presence)

1 Like

I am new to this so the above is a little confusing. Well actually a lot for me. If you could mach something up I would greatly appreciate it. I was thinking the same thing on changing the trigger from the TV plug back to the temp sensor and put the plug back in the required expressions but I don't know how to get the temp sensor readings into the system quicker to make them trigger a rule without waiting on all of entry.

I think conditional triggers may work and that you don't need both power level and active motion.

Required Expression
PB is True

Trigger Events
Power level of TV Plug reports > 50 - ONLY IF(Temp Sensor <= 70)
OR
Temp Sensor <= 70 - ONLY IF(Power level of TV Plug > 50)

Actions to Run
Set PB False
On: Heater Plug
Wait for event: Temp Sensor >= 71 OR Power level of TV Plug <= 50
Off: Heater Plug
Set PB True
2 Likes

I never thought of doing the triggers this way. Question though if the conditional is a PB will it pull from any private boolean that there is or just the one in this rule?

Private boolean in the required expression is for the rule you're currently in.

3 Likes

So I tried setting the rule up the way you suggested. Just wanted to give you some feedback. When putting a PB in the required expression the rule triggered just as I wanted to start. However when I make the PB false it basically shut the rule down because the required expression was not met. So therefore when my upper temp was met the heater didn't shut off.

So I changed it. I removed the required expression all together. Removed the PB toggles from the rule. Changed the "Ignore Triggers Events While Running" setting to on in hopes that will prevent the rule from constantly triggering while running. That was the point of the PB to begin with.

Interesting. Required Expressions only apply to triggering the rule. It should have no impact on a rule that's already executing. If you would go back to the previous way, I'd be interested in seeing the logs for the heater not shutting off.

2 Likes

Sure I don't mind at all when I get back where I can. Which logs do you want to see? Just make sure I get you the info you want.

Logging for the app and for the temp sensor should be enough.

I know how to see the logging for the temp sensor. Where do I pull up the logging for the app?

Take a look a this page on logs

https://docs2.hubitat.com/en/how-to/collect-information-for-support

I changed it back to the rule with PB as a required expression. This time it worked exactly as it should. It shut off when the temp got above the upper limit. I attached the logs but you can see it worked exactly as it should.

I obviously didn't do something correctly in the first rule I wrote.

This rule should work to achieve what I want. Thank you and everyone else for all the help that has been given.

1 Like