Device Handler poll REST api?

scheduling

(Raphael Hsieh) #1

I’m having a difficult time getting my device handler to poll a local REST endpoint I have set up.

In my “installed()” and “updated()” methods, I have a

runEvery1Minute("poll")

Then I have a poll method:

def poll() {
    return new physicalgraph.device.HubAction(...
...

finally I have a parse method that is supposed to consume the result of the request

def parse(String description) {
    ...

On my local server I am logging all incoming requests. However, I am not seeing these requests come in ever. I can trigger the request to fire if I put the HubAction in a different method and trigger it manually. But it doesn’t seem to work within a schedule ?

Does anybody have any ideas what I might be doing wrong ?


(www.rboyapps.com - Make your home your butler!) #2

you need to use sendHubCommand(hubAction)


(Raphael Hsieh) #3

From the documentation found here: http://docs.smartthings.com/en/latest/cloud-and-lan-connected-device-types-developers-guide/building-lan-connected-device-types/building-the-device-type.html#overview

When a command method of your Device Handler returns an instance of a HubAction, 
the SmartThings platform will use the request information within it to actually perform 
the request. It will then call the device-handler’s parse method with any response data.

If I use sendHubCommand(hubAction), does that mean I don’t need to return it from the command ?


(Raphael Hsieh) #4

Right now I have a local server running that returns a simple string.
When I call the sendHubCommand(hubAction), I just get a response of “{OK=NULL}” instead of my string.

Any ideas what this means ?


(www.rboyapps.com - Make your home your butler!) #5

That only applies when the platform makes the call to the method or is user interactive initiated (button)