Access device (or SmartApp) via API / Oauth / REST

Kit? Check. IDE access? Check. Written a basic app? Check.

Now I curious if it is possible (and how) to send a command to control a Smart-connected device from a third-party web service. All I’m trying to do right now is turn on a switch, e.g., switch.on.

First, I’ve read that OAuth currently isn’t implemented fully yet. (not sure though). Second, using a Basic Authorization header having my username/pass, I can do some things with the API and get info about my devices.

For example, using Fiddler, I can send an HTTP GET and get some info regarding my hub, devices, etc. For example, sending this —{my_device_id}/ — returns some JSON about my device.
my_device_id is found by looking at the URL of one of my devices in the IDE environment.

On github, I found a list of API commands (NOT device commands):
This .js file has these two lines of code, which are somewhat useful:
var urlRoot = ’’…
sendDeviceCommand : urlRoot + ’devices/{id}/commands/’

I also found this:

which, in function changeDeviceState(args,data) has

So I assume that a proper way to send a device command to a device is via HTTP POST to{id}/commands

{id:[supported command]} in the body as JSON.

However, I’ve tried everything I can think of to send a command to my device. {id:on} {switch:on} … etc.

Is this possible? Can anyone provide an example?

Also, is control of a device limited via SmartApps? If so, can anyone provide an example of sending a command via third-party web service to a SmartApp to then control a device?




1 Like

@snoopbuild - See this thread for an answer to your question:

Thanks @dlieberman