Before i begin, i will assume that you know what the Arduino IDE is and you know how to put code in the NodeMCU.
A reed switch will close when a magnet is put near it.
In this simple circuit when the reed switch close, the led will turn green and the buzzer will activate.
You can replace the reed switch with any type of switch.
You can also add a resistor between the buzzer voltage line, to make it a little less annoying
The code is in the link section, copy and paste it in the arduino IDE.
The wiring diagram is in the image section.
You can also support me by purchasing the sensor kit that i use for my projects, from the amazon link.