With "smart" appliances that can be controlled, there's often a community integration to HomeAssistant ... and then there's the free EMHASS addon which will optimise for profit, or self consumption based on energy prices (both incoming and outgoing) as well as any on-site generation (e.g. Solar PV) batteries etc. etc.
Neat piece of open source software.