We do this all the time.
Devices/Gateways may go online/offline quite a bit due to mobile network unreliability in remote locations.
However we don’t want to see alerts if it only drops out for a minute
So our workflow accepts events for a collection of devices and for each device that it receives a payload records a timestamp (last seen) for the device (deviceid) using the store value node.
In the same workflow we have a timer that retrieves your list of devices (ie by tag or other criteria).
Then use the loop construct loop over each device
- retrieve the last seen time for the device use the get value node.
- Check the time since last seen (function node),
- Use a latch node to check if its greater than the period you want then create an event for the device or reset latch if the time period has dropped.
I would then create a separate workflow that looks for certain types of events created which then might send an alert.
This keeps the other workflow simple and can be used for multiple workflows that may identify critical events.
Many of our devices are on the other side of a gateway so they don’t inherently go off line because the gateway is online, In that scenario the gateway is polling devices continuously (modbus), and if it can’t reach the device we still generate an update to losant, stating the payload is empty (ie no data from the peripheral). In this case each time we get an empty payload we increment a counter for that peripheral, and decrements that counter when we receive real data. Then if the empty payload exceeds a specific count (evaluate with a latch) we then emit an appropriate event.
Hope this helps