Switching from heating methods / depending on the Price

Hello everyone, I’m searching for a method to save some money, actually the price of gas is getting more expensive than electricity, so that I began searching for a method to switch between one or another. Like having a water heater on when the price of electricity is good.And having the gas boiler of. Does someone have any idea how to create such a thing?

Germany Rheinland-Pfalz…