best/easiest way to program p2p communication for this project

hello everyone, I am very new to prgramming and arduinos and I need some guidance.
I am building a project to control the AC unit on my Airbnb. The idea is to shut off the AC (using IR) if a window/door is detected to open (using alarm magnetic contacts).

I managed to build the plain version with one nano and it works, although the problem is that the nano doesn't know the state of the AC (On or OFF) and keeps sending the OFF command even if the AC is not used and the windows are open.

So I thought that the way to go about this is using two (or more) nodemcu ESP8266's which I found cheap, have one (no1) mounted next to the IR receiver of the AC to record the IR commands from the AC remote and know what state the AC is, and the other (no2) esp8266 on the balcony door or windows with the magnetic contact and IR transmitter.

The idea is that when I turn ON the AC with the remote, no1 receives the IR command too and knows the AC is turned ON, sends a command to no2 to check whether the door is open, if the door opens then no2 sends a IR command to the AC to turn off (which no1 picks up too and knows the AC is now OFF too).

What's the best way to go about this ? UDP/HTTP ? Can you point me to similar project example code that I can copy/modify ? Thanks

Could you use a current sensor on the power lead to determine if the AC is running instead of intercepting the IR signal.

that's actually a great idea, I didn't even think of it... much easier to implement on my current/working setup. Thank you!