Pool Pump runtime depending temperature

Hello everyone, I’m new here.

I have a switch and a water temperature sensor running in home assistant
I would like to control my pool pump runtime depending on the water temperature:

from 10-15 degrees she should run 1 hour (13-14pm)
from 15-20 degrees she should run 2 hours (13-15pm)
from 20-25 degrees she should run 4 hours (8-10am, 14-16pm)
from 25-30 degrees she should run 6 hours (8-10am, 12-14pm, 16-18pm)
from 30< degrees she should run 8 hours (7-9am, 10-12am, 13-15pm, 16-18pm)

What is the best way to do this?

BR Tom

If the schedule is based on water temperature that means, while the pump is running and the temperature is changing, it might increase/decrease its operating time.

For example, if the temperature is 20 the pump runs for 2 hours from 13:00 to 15:00 but if it increases to 20.5 at 14:50 then it modifies its schedule and continues running until 16:00.

Is that how you want it to work? If not, how do you envision a changing water temperature should be handled while the pump is running?

that’s a good point.

While the pump is running, it is not necessary to change the running time.

it might be better to set the temperature for the control at 4 p.m. every day

Your requirements indicate the schedule can start as early as 07:00.

The water temperature is highest on the evenening. Maybe this is better for the schedule.
The schedule should be between 7am to 6pm to cover the pump with pv electricity