SmartApp locationHandler called instead of device parse

(Alan Penner) #1

I’m working on a Hue app. I have the SmartApp, and a Hue Bridge device. The documentation says:

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.

In my SmartApp, I have this:


I’m my device handler:

command "discoverBulbs"
def discoverBulbs() {
    log.debug("Bridge discovering bulbs.")
    def host = this.device.currentValue("networkAddress") + ":80"
    def username = this.device.currentValue("username")
    def serialNumber = this.device.currentValue("serialNumber")

    log.debug("${host} ${username} ${serialNumber}")

        def result = new physicalgraph.device.HubAction(
            method: "GET",
            path: "/api/${username}/lights",
            headers: [
                HOST: host
        return result

According to the above documentation, return the HubAction from the command should pass the result to the device handler’s parse function. Instead, it’s being passed to my SmartApp’s locationHandler.

What am I missing here?

(Alan Penner) #2

Well, I found the answer to my own question here: Sending GET requests

Turns out the device’s deviceNetworkId needs to be the MAC address of the device for the result to go to the parse function. I had been using the Hue bridge’s serial number, not MAC.