[Solved] Creating Watchdog Timer

I’m trying to create Losant workflow that acts as a watchdog timer for my Particle devices. I’m using the Particle integration to listen for Particle events, sent approximately every 20 minutes. If it’s been too long between events, I want to know via an alert

It seems like between the Latch block, Timer, and Conditional I should be able to do this, but for the life of me can’t figure out how. I don’t want to “ping” the device because it’s typically in sleep mode and I would also like to not use up the cellular data.

I’m guessing I can store the timestamps from each device and use the timer block to check each timestamp and compare that to the current time. But this seems bad and cumbersome. I really like the ability of certain blocks to take an “identifier” variable so they can function for multiple devices. If someone can think of a way to use one of these blocks for this function that would be amazing.

Thank you!

Hi

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

Cheers

Tim

Brilliant! Just about what I was imagining - though I didn’t consider using the loop to access each device. I’ll give it a go!

This seems like a critical piece of functionality that could/should be baked into a single Losant block, but I also see the value in not making a new block for every unique function. Eh.

We did a little brainstorming internally on this and we’re going to add a Device Inactivity Trigger as the first step. It will allow you to configure a single device or tag of devices (just like the Device Trigger node), and then also accept a number of minutes that a device must be inactive before triggering. Inactive will be defined as amount of time that has passed since a device last reported state.

2 Likes

@Brandon_Cannaday

Woah! That would be intensely great! Looking forward to it, and thank you!

@Zachary_Hirschtritt we just released the Device Inactivity Trigger. Hopefully this solves your use case!

2 Likes

:star_struck: brilliant! :star_struck:

super, very crucial feature! I like the solution @Tim_Hoffman suggested, but I am also for making things simple when it comes to basic functionality!

Great feature!! just what I was looking for. I can’t wait to try it out

I’m using the inactive alert and was wondering how I could get an alert every 10 minutes from when the device has been inactive?

The Device Inactivity Trigger only triggers once when a device becomes inactive (and only resets once the device reports state again). If you want an alert every 10 minutes, I’d probably use a Timer Trigger instead, to run a workflow every 10 minutes and check the last known state of the device - and if it was more than 10 minutes ago, send an alert.