So you need to get the state of rain…
Do you have a rain-sensor or does your weather authority provide reliable ‘past-rain’ data?
There is a current thread on DIY rainsensor
DIY Zigbee rain gauge - Share your Projects! - Home Assistant Community (home-assistant.io)