Two nodes "A" and "B" emit payload.MotionDetected with a value of either 1 or 0 and a Function node adds a timestamp, payload.Time, with Date.now() and a Change node applies a Topic (to differentiate A from B).
A Switch then filters these messages, allowing through only MotionDetected values of 1. These are then Joined to create a key/value object using Topic as the key.
The goal is to compare the timestamps to see which is greater (happened most recently).
The comparison in a Function node is trivial, but I am unsure how I can ensure I only act when I have a pair of messages from BOTH - rather than a pair of messages from ONE.
I'm thinking of discarding a message from A that is not accompanied by one from B within a certain timeout OR if the next message was also from A to discard the first (and continue waiting for one from B) and vice-versa. I think I need something like a reverse deadband RBE node somewhere, but I can't get my head around this (whereas the act of drafting a question usually clarifies it for me)
Any ideas/help gratefully acceppted!