I’ve been really enjoying playing around with the particle rules engine. I’ve implemented real time alerts to slack following the guide at: https://docs.particle.io/tutorials/iot-rules-engine/real-time-alerting/
Near the end it describes a way to send alarms if a device hasn’t published something in 2 minutes or so. This is fine for 1 device or a few even. However when I have a fleet of for example over 10 devices, using the implementation from the guide would mean that I have a subscribe node for each new device in the fleet which is not really scalable.
I was thinking maybe I could fire off a node function every 10 minutes which checks/pings each device in a fleet, but I wouldn’t know how to implement that in the rules engine after retrieving all devices in the fleet. This would be something similar to a “for each loop” I guess. Any suggestions are much appreciated!
Getting a notification about an offline device* should be something we can setup from the dashboard. Without need of the rules engine. But at the moment the online/offline indicators on the dashboard aren’t robust/accurate enough for this.
- Obviously you’d want a
for condition so the alert only fired if the device stayed offline for five minutes or more. And also you’d want to be able to toggle alerts on/off for different devices.
I made a rules engine example for this.
- It works with a product in the console
- If any product device stops responding, a notification is generated
- Automatically updates as devices are added to the product
Awesome, thanks Rick. Sorry to further extend this, but I’m not exactly sure how implement this for my whole fleet. I noticed that that the get device list particle api only returns 25 devices due to the pagination system. I have about 85. How might I go about doing a loop through the pages? Or perhaps I could change the number devices per page. Thanks again Rick, super helpful.
EDIT: Also for the check for non responding devices node, isn’t it just going to return after finding the first non responding device? Or are we relying on the fact that it’ll eventually get around to every device since the next time it runs after 10 seconds it’ll go onto the next offline device.
Yes, it only works with 25 devices. There’s a bug in the Particle API node where the url is ignored on the 2nd and subsequent uses, so I can’t actually iterate all of the device yet. But once that’s fixed I’ll release a new version that handles pagination.
Yes, it does return after the first failure. I originally wanted it to return the array of failed results in one call but it didn’t work right. Eventually you’ll get all of the notifications, it will just take a number of calls.
@rickkas7 How will we know when the node gets fixed?
That’s a good question - we don’t really have a notification system in place, but if you watch this thread I’ll make sure it gets updated when the Particle node is fixed.