You need a smart button pressing device. Something like :
I have not used this personally, but I have a home assistant setup that does operate based on real time energy prices and it’s awesome.
Yourself for caring about everyone else’s bathroom use
The Hershey ice cream company, which (this is real) is not associated with the famous chocolate maker