Geofence filter nodes: how to work with non-matches?

In my flow I work with payloads containing geo-coordinates and about 40 nodes representing geofences. Each payload passes through all fence filter nodes (in parallel). When the coordinates lie within a fence the node title is added to the payload and the payload is returned. If a fence does not match nothing is returned. All outputs end in a single string of nodes for further processing. The fences are exclusive, there are no overlapping areas.

What is a good approach to work with a message that did not match any fences (i.e. that is not returned by any geo-fence node)? A possible workaround I see is to set a match variable to false before the matching nodes and have a function node directly after the fences which would set it to true. If in the same flow I check the variable 250 milliseconds later I would know that there was no match.

Is there something better, less error-prone?

You could put the nodes in series and get each one to add to an array of matches in msg.matches (for example). Then at the end you will know all the matching fences, if any. That would also cope with overlapping areas. If you know there will never be any overlapping then don't bother with an array, just put the name in msg.match.

Thanks for your comment and suggestion. That's exactly what I ended up doing.

As an additional twist the chain starts with two parallel nodes. One with the "At Home" fence after which additional processing starts and an exclusion fence which sets the home property to false so that when all other areas were checked and there was no match I at least know that the object is not at home.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.