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 — https://graph.api.smartthings.com/api/devices/{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): https://github.com/alanleard/ti.smart/blob/master/src/ti.smart.js
This .js file has these two lines of code, which are somewhat useful:
var urlRoot = ’https://graph.api.smartthings.com/api/’…
sendDeviceCommand : urlRoot + ’devices/{id}/commands/’
I also found this:
https://github.com/alanleard/SmartThings/blob/master/app/controllers/dashboard.js
which, in function changeDeviceState(args,data) has
body:”{id:”+args.supportedCommands[evt.index].id+”}”
So I assume that a proper way to send a device command to a device is via HTTP POST to
https://graph.api.smartthings.com/api/devices/{id}/commands
with
{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?
Thanks!