It works fine, but when the door is left open, the light turns on randomly. Apparently, the contact sensor reports its state from time to time, not just when it changes.
Play around with a toggle node that is set to pass messages only ‘if changed’, and a trigger node at e.g. 30 seconds. I have some Bluetooth sensors that constantly resend on or off messages and I’ve managed to get them working perfectly that way.
If it doesn’t work for you then you should post this on the Node-red forum.