Best practice to automate planning of energy consumption

Hi :wave::

I have just migrated from another home automation system to Home Assistant, and now I’m looking into how to migrate automations. I realised some of my existing automation requires some planning ahead. For example: at midnight I look into current water tank temperature and electricity price tomorrow, calculate how long time it takes to heat the water to desired temperature at 7:00 (40C) and 17:00(50C), then find when to start/stop heating during the day at cheapest hours.
What’s the best practice to implement such in Home Assistant? I’m think an automation to calculate start/stop time, store them in input_datetime helpers and trigger another automation to turn on/off or adjust temperature. But it’s messy to have many helpers, is there a cleaner way to do so?
Thank you!:pray:

40C do not sound healthy.

Thanks I have anti-legionella runs monthly to heat water to 65, and everyday before 17 I make sure the tank temperature is above 50 (hence my question), 17-21 is the expensive period to turn on water heater in my area

Any suggestion on what’s the best practice?
Or if please share if you know some integration/blueprint which can help, appreciate your input!

Well, you need to go above 60C and preravly 65C.

Regarding best practice, then I do not think there is one.
The amount of water you need to heat and the power available to do that is different from user to user and makes it somewhat hard to script, especially with different pricing schemes.
Many markets are also soon, if not already, moving to 15 slots for pricing which will make it even more complex.