# Rule for if x for y minutes then?

Hi,

I have a solar pool heater that I want to turn on when the roof temp rises above 80 and turn off below 80. The problem is in the morning the temp fluctuates around 80 for a few minutes (79.5, 80.5,79.7,80.3,…), so with a simple rule it turns the pump on and off a few times until the temp doesn’t dip below 80 anymore.

What would a rule need to look like that waits until the temp doesn’t dip anymore?
Eg. If temp > 80 for 10 min then turn on pump.

Same for turning it off. If temp < 80 for 10 min then turn off.

If have created two rules. If that the right way or could I combine on/off in one rule? How would I do that?

I would simply add a 5 or 10 min delay to the rule

You could do this with 1 rule instead of 2.

First, you don’t need the predicate condition.

The rule can be triggered by temp>80

Turn on pump
Wait for temp<79 -> Delay X minutes
Turn off pump

What that will do is that once the temperature is less than 79, it will wait X minutes and if it is still less than 79 at that point, it will go to the next line (Thanks @bertabcd1234 for showing me this (by showing someone else) yesterday!).

If the rule is triggered again by the temperature going over 80, it will automatically cancel and re-start the wait.

1 Like

Like this?

1 Like

Close! You need to put the delay on the Wait line rather than on the Off line for this to work the way you want it.

Oh, and my apologies - you have to do a wait for conditions, not events… Did I mention I just learned about this yesterday…?

1 Like

Next attempt
Thank you for the tip - wait for condition is wait for rule in 2.2.9.

1 Like

So I expanded my pool heater automation. I’m running a fake-101 with a ds18b20 temperature probe in my pool and a temp sensor on the roof with the solar panels.

I would like to achieve the following:
Between 9:00 am and 3:58 pm (when energy is cheaper) AND
If water temp is below 82 F AND
If roof temp is greater than water temp
Run the pump

If water temp is above 82 OR it’s 3:58 pm, turn off the pump.

I came up with the following but the temp based power off does not seem to work.
Any suggestions?

The rule below sends me a temp notification every few minutes. Is there a way to only get one message when the threshold is crossed in both directions?

A few thoughts for you. Turn on logging and see what's happening. I would also consider making the roof temp > pool temp a restriction and the pool temp the trigger. I'd also update the Wait to When time is 15:58. The rule is running every few minutes because the roof temp is changing (quickly I would guess) and triggering the rule which sends notifications for each triggering. You could try to incorporate a boolean variable to limit the number of times or try the Notification app.

Hi,
I reshuffled the rule based on your input. Now the rule is not firing to turn off the pump, nor turning it off if I turn on the pump switch manually.

If water < 82 turn switch on
If water > 83 OR time = 15:57 turn switch off

What am I missing?

@christian.busch Did you turn on the rule logging? If so, post the logs.

It might be waiting for a new sensor update from the pool temp sensor in order to trigger. Is there a way to trigger on temp without having to wait for a deliberate update from the temp sensor?

@christian.busch just use the Run Actions button

Well I meant automatically not manually.

Another option is to swap out your temp sensor with a virtual temp sensor. You can manually set different virtual temps to see how your rule triggers and reacts.

1 Like

Thank you for everyone’s input.

The the temp > 82 check needs to be triggered by the sensor actively sending an update from the sensor and my temp changes were not big enough to trigger frequent updates.

So I solved it by using a timer trigger and moving the temp check to the actions.
This seems to work now.

What do the experts say? Does that rule look fine or is there a better/more efficient way to achieve this?

I would normally suggest some deadband between the On and Off temperature but since you're triggering every 30 minutes I don't think it's needed. You could rewrite your two IF-THEN statements into one IF-THEN-ELSE. I'm not sure of the point of the Cancel Delayed Actions so you can eliminate that action. I would definitely change your Wait for event to 15:59 or later. I'm not sure when you 30-minute trigger starts but if your rule triggers at 15:58:30 there is nothing to turn of the heater until 9:00 the next day. Edge case? Probably but why not eliminate it if you can.