@gerriko, fair questions i have provided almost no requirements, i apologize.
So what i am trying to do is send a request to smartthings .
I have gone through the documentation and i have all the specifics i need to send a request by typing the following to a web browser link and i see a switch turning off or on.
More specifficaly, the browser command is:
http://graph.api.smartthings.com/api/smartapps/installations/IC/switches/DID/on/?access_token=AT
where:
IC = installation code (something like: 26d339b1-3cef-4d4e-ba95-xxxxxxxxxxxxxx)
DID = Device ID (something like: 26d339b1-3cef-4d4e-ba95-xxxxxxxxxxxxxx)
AT= access token (something like: 26d339b1-3cef-4d4e-ba95-xxxxxxxxxxxxxx)
According to the documentation:
( http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/tutorial-part1.html ) towards the end of the page:
Make API Calls to the SmartApp
Using whatever tool you prefer for making web requests (this example will use curl, but Apigee is a good UI-based tool for making requests), we will call one of our SmartApp endpoints.
From the simulator, grab the API endpoint. It will look something like this:
https://graph.api.smartthings.com/api/smartapps/installations/158ef595-3695-49ab-acc1-80e93288c0c8
Your installation will have a different, unique URL.
To get information about the switch, we will call the /switch endpoint using a GET request. You’ll need to substitute your unique endpoint and API key.
curl -H “Authorization: Bearer ” /switch
This should return a JSON response like the following:
[{“name”:“Kitchen 2”,“value”:“off”},{“name”:“Living room window”,“value”:“off”}]
To turn the switch on or off, call the /switch endpoint using a PUT request, passing the command in the request body. Again, you’ll need to substitute your unique endpoing and API key:
curl -H “Authorization: Bearer ” -X PUT /switch/on
Change the command value to “off” to turn the switch off. Try turning the switch on and off, and then using curl to get the status, to see that it changed.
Tip
You can also pass the API token directly on the URL, via the access_token URL parameter, instead of using the Authorization header. This may be useful when you do not have the ability to set request headers.
I have also seen some python code where they do this:
def toggle_st():
url = 'YOUR_API_ENDPOINT'
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
data = '{"command":"toggle"}'
r = requests.put(url, data=data, headers=headers)
def toggle_st(light_name):
info=oauth_setup()
switch_id=light_name_to_id(light_name)
url = “%s/switches/%s” % (info[‘endpoint_uri’], switch_id)
syslog.syslog(“Toggling %s with URL: %s” % ( light_name, url ))
data = ‘{“command”:“toggle”}’
r = requests.put(url, data=data, headers=info[‘headers’])
although i havent had too much luck but havent concentrated on their code yet.
Also according to this link:
And after making the proper PUT request with the body of “{command: off}”, I was successfully able to turn off the switch!
I’ll add more as I keep moving along here, but I wanted to document this so I don’t forget, and hopefully it helps someone doing some deep digging that comes along this.
Since I had some issues with the Node side of things, I’ll add some info here as well. I ended up installing the Requestify package, which let me send the body data properly. For some reason the https package using “request” wouldn’t work – I couldn’t set “body” in the options for the request.
I hope this is enough information for some help
thanks again