I’m trying to write a smart app to manage my Hue lights that will automatically turn them on with a specific scene set. The Hue REST API supports this behaviour (can tell a group of lights to recall a given scene) so I know I’m set there.
My problem is in how to actually send these requests from the SmartThings app to the Hue REST API. Going in I had assumed this would be the easy part, but it doesn’t seem to be that way.
So as I understand it, HttpGet/HttpPost don’t work on the local network. I’ve discovered SendHubCommand method, but I’m struggling to get it to work.
Based on what I’ve been able to find on these forums, my code currently looks like this:
def httpRequest = [ method: "GET", path: "/api/hueUserName/groups", headers: [ HOST: "192.168.1.73", Accept: "*/*", ] ] def hubAction = new physicalgraph.device.HubAction(httpRequest) sendHubCommand(hubAction)
This compiles and executes at runtime, but it doesn’t appear to actually do anything. I’m listening for responses by subscribing to location event and looking for something that looks like a response to my request, but nothing ever comes back.
I’ve gone through the code for the Hue (Connect) app and it seems to send requests in a similar way to this, though I’ll confess that I find the code in that app to be pretty confusing.
Any help would be greatly appreciated.