Do I need a repeat rule for turning on / off switches based on Temperature?

Greeting!

I have Solar so I want to use electric heaters instead of my furnace. What I am trying to achieve is from 11:30pm - 4:30am I want my electric heater to turn on if the temp hits 68 or lower and turn off at 70.

Did I do this correctly?

Thanks in advance.

1 Like

Hi - this is how I would create your rule.

2 Likes

Not quite. Actions only run when a trigger event happens (or if the actions themselves explicitly schedule or subscribe to some event--but an IF won't do that; it's just evaluated at the time of execution, then any matching block will run, and the execution will move on).

The easiest way to make something like this happen is to set up a rule that looks something like this:

Required Expression: Time between 11:30 PM and 4:30 AM

Trigger events: Temperature <= 68

Actions to run:

On: Heater
Wait for event: Temperature >= 70
Off: Heater

There are some nuances to consider, like the fact that the above won't turn anything off at 4:30 AM directly should it happen to have been turned on before that time. There are certainly ways to address that if there is a need.

The rule posted above while I was typing is basically the same, except the addition of Private Boolean prevents the actions from starting over again once they've started until you reach the end. Basically, that will avoid possibly repeat "on" commands to the device. In most case, commanding something to be on that is already on is harmless, though there's usually no need to do so. Basic Rule should also be able to handle this case if you wanted an alternative approach (start with the temperature <= 68 and go from there, and add a restriction for time when you're done).

As is usually the case, there is more than one way to get things done. :smiley:

1 Like

Thanks so much for the prompt responses!! This helps with also future rules I create.

1 Like

Maybe try something like this virtual thermostat and you don't need any rule. Other than turning it on and off on the days and time you want.

1 Like

i would just do this.. everyone has there own opinion

required expression time..

trigger temp changed

if temp <= 68
if switch off then switch on
end if
else
if switch on
then switch off
endif
endif

or you can remove the check for switch state as not 100% necessary as the hub should klnow the state but i like it for completeness

2 Likes

That doesn't account for the time of day (a requirement from the OP) or the space between 68 and 70 °F, but, yes, something like this could work with a couple changes. The required expression does have the advantage of preventing the rule from even triggering (or the app waking at all) outside this time, and the specific trigger plus "Wait" in the actions allows you to avoid the extra logic needed to check the temperature since there is no need to due to knowing why the rule triggered. That type of trigger is now my preference for this reason, though in earlier Rule 4.x days the pattern above was also seen quite a lot.

So yeah, as usual, there is more than one way to do things. :smiley:

it does see first line.. required exression time

1 Like

Ah, yes, didn't notice that blurb.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.