General "design/architecture" for 2-way comms between esp32 rainsensor device & HA?

Hi,

I’m very much a newbie to HA. I have it running and have used it to control a smart bulb in testing, but that is about as far as it goes right now. We are in the middle of building an extension and once complete I’d like to get HA really working for me. One of the first things I want to do is this:

I am building a rain sensor using the Hydreon RG-9 and an ESP32 that is going to sit in a waterproof box outside somewhere, with a battery, and connect over wifi at some frequent interval. This is now breadboarded on my desk and waking/sleeping and comms are working nicely between the RG-9 and the ESP32 (I’m using native C arduino code, not ESPHome or other platforms).

In my house we have a newly installed electric opening/closing rooflight in our new utility room (still at first fit electrics so not actually working yet). I have bought a Shelly Plus 2PM to sit behind the manual wall rocker switch to allow control/monitoring from HA.

My current plan is this.

The Rainsensor/ESP will wake up from deep_sleep every few minutes. The first thing I need it to do is to get the status of the Shelly cover (the rooflight) presumably by asking HA for the info. If the cover is closed, then the rainsensor can go back to sleep. If the cover is open, then I will start checking for rain. If rain falls, then I’d like the ESP32 to contact HA to tell the Shelly device to close the cover. Once it is closed, then the rainsensor can go back into deep sleep and the cycle repeats.

So my question is really more general on the optimum protocol(s) to use to communicate between the ESP32 and HA. And what docs should I be looking at? My guess would be to use MQTT but maybe there are more suitable approaches available?

TIA

Al