December 11, 2016, 9:37pm
What’s the best practices for polling devices? I’m trying to poll a device every few minutes to check the status. The device is an HTTP API.
Right now I’m just testing with:
def freq = 1
schedule("0 0/1 * * * ?", poll)
getStatus() will go out and fetch via HTTP the status of a device. The problem is, nothing is polling right now. I’ve been watching the logs waiting for “Polling…” but nothing shows up.
December 13, 2016, 12:11am
Well, that not my issue.
My issue is the device is not being polled AT ALL. ST says it should be every 10 minutes, this is definitely not happening.
December 13, 2016, 12:30am
Polling was newer reliable. I think they’ve stopped doing that long time ago. See the Pollster thread.
Please note that excessive polling of some devices (particularly Zigbee and Z-Wave) may cause network congestion and lead to degraded system performance. Therefore, polling rate faster than 5 minutes is not recommended. The author of this software bears no responsibility for your system performance. Use it at your own risk.
I don’t claim originality of the idea, but I needed one badly for some of my projects and didn’t find anything among the shared apps. So there it is…
Many SmartThings devices rely on polling to periodically update their status. These devices have ‘polling’ capability and provide poll() function that the SmartThings polling engine calls approximately once every 10 minutes. Unfortunately, SmartThings polling engine proved to be unreliable and sometimes it stops working…
December 13, 2016, 12:33am
Hmm, so if I have a custom switch type that runs off an HTTP API. There’s no way to have ST automatically go out and check if it’s on or off? Unfortunately I cannot have the switch update ST so I have to rely on ST to reach out and touch the switch itself.
December 13, 2016, 12:36am
No, that’s not how things work. ST does not poll switches. Your switch has to send an event when it’s state is changed. So you’ll need to send an event in your http handler. No polling is necessary.
December 13, 2016, 12:54am
Insteon would never support that in a million years.
I’ll work around it I guess.
December 13, 2016, 3:11am
That’s what Pollster is for.
December 13, 2016, 3:17am
Which insteon controller are you running? ISY or?
December 13, 2016, 5:02am
I’ve already built all the device types for all my devices but cannot poll if it turns on or off at the switch.
Edit: I can poll it but ST doesn’t poll it automatically like it should.
December 13, 2016, 12:45pm
I think this was a design choice. ST is event driven in that respect. Pollster, as mentioned, was a solution for your use case.
December 13, 2016, 5:14pm
Yeah that’s never going to work or be reliable. I use a mix of Pollster rest API call and google apps scripts to make the request every few minutes. Works perfectly and I don’t have to rely on smartthings for any scheduling.
I have an ISY so a bit different but same concepts needed.
December 13, 2016, 9:02pm
Rumor has it, that device handlers can now call
runIn() to schedule callback execution. If that’s the case, you can create self-polling devices.
December 13, 2016, 11:59pm
Adding a runIn() to poll() forces it into a loop.
We have liftoff.
December 14, 2016, 12:02am
Just tried it myself.
schedule() works as well. Awesome!