Polling not running?

Hey guys,

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 initialize(){
    log.debug "Initializing.."
    def freq = 1
    schedule("0 0/1 * * * ?", poll)
}

def poll()
{
    log.debug "Polling.."
    getStatus()
}

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.

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.

Polling was newer reliable. I think they’ve stopped doing that long time ago. See the Pollster thread.

@geko

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.

Ideas?

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.

Ouch. :expressionless:

Insteon would never support that in a million years.

I’ll work around it I guess.

That’s what Pollster is for. :slight_smile:

Which insteon controller are you running? ISY or?

Hub 2422

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.

I think this was a design choice. ST is event driven in that respect. Pollster, as mentioned, was a solution for your use case.

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.

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.

Lightbulb!

Adding a runIn() to poll() forces it into a loop.

We have liftoff.

1 Like

Just tried it myself. schedule() works as well. Awesome!