Automation based on numeric state with a minimum on time per day

Hey,

Currently i implementated a pump control with 2 automations, one to start the pump if the sensor value is higher then a configured value for 5 minuts, and a second one to stop the pump if the sensor value is below a certain value.

But its not garanteed that the start event happens, if this is not the case, i would still like to start the pump for a minimum amount of hours per day.
so if the pump is not online for at least 3 hours a day, then HASS should start the pump independant of the sensor value. But this should not happen if the pump already ran for 3 hours that day.

Not sure how i can do this in an automation, any sugestions?

So you want to check this at midnight?

How about adding a trigger to your “pump on” automation that triggers if the pump has been off for 21 hours and 1 minute. This could trigger at any time. i.e. the pump must run for 3 hours in any 24 hour period to prevent this trigger from happening.

thats an interesting approach, and it could work.

how would you trun of the pump again (if its started because it has been idel for more then 21hours)

Hmmm, tricky. The sensor could already be below the trigger point if the pump was turned on with the time trigger.

Add a maximum run time state trigger (pump on for…) to the off automation?

This could switch off before the sensor is below the trigger level in the case of the pump switching on because of the sensor. So add a numeric state condition (sensor must be below the off level).