Hardware Pollster (Schedule Fix?)


(John) #1

As we all know, scheduled tasks keep failing. Many have tried varies ideas of kick starting the schedules or events to keep them running. Some have suggested tying motions or temp sensors to apps since event driven automations work. The issue here is the events are sporadic (too many, too few, not reliable, need more cats).

I built an Arduino project this summer that basically monitors the flow of water in a sump pump and also monitors radon (technically not that selective, other radioactive nuclides would also be picked up), but the point is one of the sensors fires every minute and another every five minutes. So I tied some apps that are more critical that they run periodically to the five minute attribute, and other than being off a few seconds here or there, it works flawlessly.

I have an Armada of Arduinos, so this weekend I was thinking about setting one up with the intended purpose of scheduling. I can easy modify it to work at intervals of 1, 5, 10, 15, etc. minutes with very little effort by setting different attributes (subscribe to the one you want). The only thing left is scheduled jobs that should occur at specific times. I have thought of a couple of ways to accomplish. Either create a schedule table directly into the Arduino, use a PC to talk to the Arduino over the USB port (crank up Visual Studio), or even use a Smart App. All have advantages and disadvantages, but overall, I think my scheduling issues could be behind me or at least improved with respect to reliability.

Technically it would be a Hardware Pollster (@geko).

And before you say it, yes, I know a database fix is coming today. Not to be pessimistic, but scheduling has never been reliable. Schedules have died for years (yes, more than one, makes it sound more dramatic). The second coming is as much a sure thing as the schedules being fixed today.

Any thoughts?


Scheduler and Polling quits after some minutes, hours, or days
External Time Source / Schedule Driver for SmartThings
(Minollo) #2

I adopted a similar approach several months ago; I’ve noticed that the Zigbee SmartThings contact sensor sends back data about its values (battery, open/close, temperature) to the hub every 150 seconds - always. I’ve changed the default device driver to mark the battery value (just pick one) as always “changed”. At that point I have a hardware pollster which I can use by just subscribing to battery events of that device; every 2.5 minutes my apps which rely on scheduled events receive a notification; I use the app’s state to track when a scheduled even was last processed; if that time interval indicates that a timer has dead, I’ll just force a processing of the (delayed) timed event, and then recreate the scheduled event.
That approach has made my whole system very reliable, and resilient to most of the issues that the ST platform has gone through during the last months. And I didn’t need any new hardware to do it.


(Geko) #3

You could do pretty much the same without resorting to hardware hacks. Just use IFTTT Maker channel to hit SmartThings REST endpoint. The IFTTT Time & Date channel allows you to create chedules. It only can run once per hour, but you cloud create many of them or use other source. If you get a lot of spam, you could use Gmail, for example :smile:


(The fish is still dead.) #4

I’m doing this to an extent with cron jobs on a Pi and REST endpoints. It works well.


(Geko) #6

That’s an awesome idea! Gotta read more about it.


(John) #7

I built the Arduino. It creates a heartbeat so devices can subscribe to various intervals (5, 10, 15 minutes) to poll, refresh, or do whatever.

I also built a Windows app that allows you to send data to the Arduino. Again apps can subscribe to it and fire at the scheduled time (set in the Windows app).


(Geko) #8

I’ve added REST API endpoint to Pollster, making it possible to use IFTTT Maker channel to do your polling. You could also you add curl command to your cron job if you’re running Linux locally on your LAN.

P.S. Pollster works like a champ with IFTTT recipe triggered by “Date and Time” channel. That channel allows you to set up a 1-hour schedule, running at either 0, 15, 30 or 45 minutes past the hour. So you can set up four recipes to achieve 15-minute polling schedule.


(Anthony S.) #9

I tried the Google Scripts https://scripts.google.com referenced above with the updated Pollster 1.5 and it couldn’t have been easier.

The following code in Google scripts will call the new Endpoint added to Pollster:

function myFunction() { var response = UrlFetchApp.fetch("https://graph.api.smartthings.com/api/smartapps/installations/your_pollster smartapp_id/poll?access_token=your_pollster_accesstoken"); Logger.log(response.getContentText()); }
Then just setup the trigger for the time frame you would like


(Chrisb) #10

Can someone dumb this down a bit for me? I understand you’re using some sort of external “heart beat” (to borrown @bago’s term) to refresh schedules, but how does that refresh work?

Is this something written into the smartapp to look for that heartbeat and then “reschedule” itself when it happens?


(John) #11

The device has an attribute that is refreshed periodically from the arduino. Apps can then subscribe to that attribute. The attribute can be updated at whatever frequency you want.


(Chrisb) #12

Gotcha, so the app itself is being modified to listen for changes (the heartbeat) and then reschedules itself whenever it hears the beat?


(John) #13

The app can be modified so that it only responds to the heartbeat. I modified the apps with a setting for Scheduler or Hardware. Depending upon which you pick, it either schedules or subscribes.

I don’t reschedule when I use it.


(Jeffrey) #14

@tonesto7 awesome - thanks for that - working great and simple!


(John) #15

I built a schedule program in Windows. It triggers the Arduino at the designated time. Scheduled events fire as expected.