For my soil moisture sensors I use a transistor with which I switch the voltage on the sensor on and off with an interval of 15 minutes.
For a rain sensor I am lucky to have an old rain sensor from a greenhouse climate system,
This sensor works in much the same way, only there are power resistors at the rear, which act as a kind of heating, these switch on when moisture or rain is measured on the sensor, and off again when they are dry.