Have a look at the EMHASS: An Energy Management for Home Assistant add on.
I use it daily for great effect.