Automation: Set a switch on at X events, but in total only for a specific time. Possible?

Hello,

I hope you can help me.
I am trying to get in touch with “automation” and I successfully added some “if…then” events.
But now I want to add a “condition” which is based on “time in total a day”.

Example:
If my solar production energy is over 600w, a switch turns on which turns the water on in the garden.
If the solar production energy drops under 400w, the water turns off.
This works perfect so far.
But of course at a sunny day the water will turn on at 9am and won’t go off until 7pm… not so smart.
If I try to set a time window, it would be bad too, because nothing will happen, if it’s cloudy at that time window…

Let’s say it’s a mixed sunny and cloudy day (what is very common here):
10:00am to 10:30am → sunny
11:00am to 11:30am → sunny
1:30pm to 2:30pm → sunny
3:00pm to 7:00pm → sunny
Rest of the day cloudy

So at my current automatism the water will flow at all “sunny times”. But that’s to much. I want, that the water will only flow for 2 hours a day at maximum. So at the time from 3-7pm the water should stay off, because the 2 hourse are reached before at that day.

At cloudy days it’s ok, if the water won’t flow.

Is this possible?

Just add a delay and turn off the water if it’s not already off. Or add a timer entity and turn off the water if the water is not already off when the timer ends.

You’d add the delay and the turn off to your turn on automation. Or you’d add the timer to the turn on automation with a separate automation to turn it off when the timer ends.

Thank you for your reply.
I am not sure if i got it.

You say, that I should at a timer entity (you mean in “helpers tab”?) and set it for example at 2 hours, when I want to let the water flow at a maximum of 2 hours a day. Right?

I don’t get the step “Or you’d add the timer to the turn on automation with a separate automation to turn it off when the timer ends.”
So I set the timer in the first step and now?

I have 2 automations: 1: Solar energy > 600w → water on, 2: solar energy <400w → water off
Now I should go to the “water on” automation and at the timer?! How?

Sorry for my bad english.

1: solar energy → 600w → water on and start 2hr timer.
2: solar energy → 400w → water off
3: timer ends → water off

1 Like

Ok, thank you.

As I understand it, either the clouds will turn the water off or at least the timer will do it after 2 hours.
Right?
That’s at good step in the right direction. I will try that. Thank you.

But what happens when it’s sunny for 3 hours, then cloudy for 2 hours and then sunny for 3 hours again? As I understand the timer-rule, the water will flow for 4 hours total at that day?!

Yep, most likely.

1 Like

Hmm ok, not really what I wanted, but it’s something. Maybe my wish is to special for home assistant.
I will try that. Thank you!

If you only want it to occur once, add an input_boolean

1: solar energy → 600w → Condition: input boolean is off → water on, start 2hr timer, turn on input boolean.
2: solar energy → 400w → water off
3: timer ends → water off
4: at midnight → turn off input boolean

1 Like

Thank you!
I will try that, but that sounds good to me.

There’s also the history stats sensor, which can count how long a switch has been on. You could use that to put a maximum on the time you supply water. So it can be multiple times, but not more than the set maximum. You (also) turn the water off when the history sensor reaches max, and only on if the max is not reached.

1 Like