Breeding tank themperatur control

Hello
I need an idea how to realize my project.
I need to reduce a large amount of water in a breeding tank in a controlled way. The temperature is kept constant at 0.5 Gard by a heater.
I manage this today with a fixed temperature variable, DS18S20 temperature sensor, and a heater

I want to:
*Over the dashboard set the start over a date
*the difference by how the temperature may fall in degre
I have a heater available for switching on and off over MQTT
The current temperature is available to me with MQTT with an accuracy of 0.1 degree

For example
I would like to lower the temperature from 24 degrees to 17 degrees from 5 October. A maximum of only 0.5 degrees per day may be lowered. Theoretically this would take (24-17)/0.5 days. Unfortunately this is not so linear, because on sunny days the temperature of the water rises more than it reduces, so I can not say that the heating must keep the temperature at the new value after reaching the calculated value. The water can rise 1 degree on sunny days without heating and fall several degrees on cold days with rain. This prevents the heating and tries to keep the water always at a given temperature.
Since this is so important, the current information must be cached, whether in a SQL DB or directly on the Raspberry. After a restart, work must continue where it stopped before the failure. This is a very slow process, but must be kept, otherwise the breeding can be damaged.

I'm somehow on the end of my brain and I always get lost in a lot of variables which I read and write from the SQL DB. The whole thing works so badly that I have deleted the whole flow several times and started from scratch. I think I need a completely different approach and hope you can show me a new direction

Initially forget about how you are going to implement it and concentrate on getting a clear, well defined spec of what should happen.
Once you have that then you can worry about how to implement it.