node red – check if an event has happened before performing an action in NodeRed

I have a door sensor that detects if its open or closed. I also have a camera which detects motion and sends an mqtt message when the motions stops.

If the doors opens, the camera detects movements and, sometime later, I receive the mqtt message. However, if I walk nearby the door, the camera also detects movement and sends the mqtt message.

What I am trying to do in NodeRed is to perform an action when I receive the camera motion message, but only if the door was open .

To do so, I have connected the door sensor to a change node to create a message which represents “door has been open”. However, when I receive the mqtt message, I have no idea how to check if the door was open to continue with the flow

enter image description here

Basically, my question can be summarized as how can I check is something has happened to continue or stop the flow

Read more here: Source link