Notification that a device is not connected to Particle

Hello,

I am working with an app company and they are asking me how their app can know that our Boron devices are not connected or online. I have a status message that the app can send to the device and if it is connected to the Particle cloud, the device will respond. The question is, is there a way to be notified or send some form of notification that a particular unit is no longer connected? Just as an example, someone disconnects this product from power for some reason, can a notification be generated by Particle to indicate the device is no longer connected? I am guessing the app company could then use this notification somehow to relay to the app to indicate to a customer their device is no longer powered.

Thanks.

@jab,

I have this same use case but these notifications are generated by Ubidots (my serial data streaming service) not Particle. Happy to share details but not sure if the Particle requirement is a hard and fast one.

Thanks, Chip

I don’t think there is a method that Particle could use to know if/when a device no longer has a connection (immediately).

You can use a Push or a Pull method, or both.
You can Push a scheduled “Heartbeat” Publish and your backend will recognize when a message is missed.
Or you can externally Pull a response from the Boron (as you mentioned doing already).

The Push method lets you know about a connection problem sooner, but is dependent on your schedule. Cellular Data and Data Operations are used for every event (Push and Pull).

Hey, I do not know any way to do that.
One alternative that can be used from your app is the list-devices message. This can be called right before the app shows the relevant screen and info to the user, and maybe periodically, or with a refresh button that the user can tap.
The list-devices response contains the online info like this:

"online": true,

Not the ideal solution, though.

1 Like

It also depends how quickly you need to know. If you can wait up to 46 minutes you can use a webhook or the SSE event stream to watch for spark/status messages. This is the most efficient, since it does not require polling.

The reason it takes 46 minutes is that to conserve cellular data, the device only pings the Particle cloud every 23 minutes. The offline event isn’t generated until two are missed.

2 Likes

Traditionally, you would use a watchdof. Most monitoring systems do it, including datadog and newrelic, you can even build them in aws cloudwatch alarms.

The concept is simple, your device hits a url or takes an action every so oftwn, when that action does not happen, you alert. Now the signal could be from a lambda or functtiin called when you publish data to an iot pipeline on aws/azure, or you could use mqtt or http calls.

But the way we do it in the reliability engineering side of the house is by alerting in the absence of activity.

2 Likes

Hi, I would like to know the specific step to setup a webhook to monitor the spark event. Thank you.

The event to trigger on is spark/status. There's no good way to differentiate between online and offline in the webhook, but if pass {{{PARTICLE_EVENT_DATA}}} to your server, it will be the string online or offline.

The rest of the configuration depends on how your server is configured.

I use a dedicated Photon as my monitor device. My other devices publish a heartbeat message every 5 minutes, to which the monitor subscribes. If the monitor doesn't hear a particular heartbeat within 8 minutes it publishes its own message to indicate a device offline status. When the device comes back online the monitor publishes an online message. The one hole in this approach is when the monitor itself goes offline, but that doesn't happen very often.