JSON issue with device handler

Is your device handler also using Hubaction to get JSON output from local LAN? If so can you post the device handler?

I just remembered that I ran into a weird situation once where something in my code was causing the method to fail, but it didnā€™t log the error or any of my debug messages.

I doubt thatā€™s the problem, but just in case, you might want to try commenting out everything in the parse method except something like log.debug ā€œparsedā€.

Same thing doesnā€™t work. Thanks.

Not an expert at this at all, but shouldnā€™t he use theā€¦

sendHubCommand(hubAction)

def refresh() {

	log.debug "Executing 'refresh'"
	
    def hubAction = new physicalgraph.device.HubAction(
        method: "GET",
        path: "/api/username/lights/1922029999",
        headers: [HOST: "192.168.8.3:80", Accept: "application/json"])
    log.debug hubAction
    sendHubCommand(hubAction)
}
1 Like

Can you try the fully qualified http with that.

I am not a hub action expert I have only parsed external calls.

Did you try it?

I tried commenting out everything except log.debug ā€œparsedā€ nothing was logged still. I donā€™t think the code in parse() is the issue as I moved the code to refresh() and hardcodded the JSON to def result = slurper.parseText() and the state were working based on the output. Thanks.

yes I tried it, doesnā€™t work as well.

Itā€™s on GitHub and it uses HubAction to communicate with a local device, but I just realized that Iā€™m sending messages to it, but I donā€™t receive a response.

Iā€™m not sure if you can get a response back from the device without implementing a service manager, but I might be interpreting the documentation wrongā€¦

"When using a LAN connected device, the service manager is used to
discover and initiate a connection between the device and your hub,
using the protocols SSDP or mDNS/DNS-SD. Then the device-handler uses
UPnP/SOAP Calls or REST Calls to communicate outgoing messages between
the hub and device."

Hi Kevin,

You are right. I created a service manager and then created a device using the service manager then using the same code I can get the JSON output.

Thanks to everyone for your kind help. I really appreciate it. :smiley:

1 Like

Is it possible for you to expand on [quote=ā€œkaznad, post:31, topic:58112ā€]
I created a service manager and then created a device using the service manage
[/quote]

I had this same issue, with parse() not getting called by smartthings running refresh().

I fixed it by not just returning the hubAction object, but by calling sendHubCommand(hubAction) in the same place.

thanks.

1 Like