Still can´t get it to work…
My python script looks like this:
import urllib;
urllib.urlopen('https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/a9cf307b-e16f-4f85-b868-69dccedf5943/switches/7B78/on access_token=xxxxxx-xxxxx-xxx-xxxxxxxx');
When I simulate my smartapp “Web Services Tutorial” I toggles my switches on and off so it seems that its setup OK.
I get this [{"name":"Läslampa Soffan","value":"off"},{"name":"Z-Wave Metering Switch","value":"off"}]
when I enter the URL.
This is the code I use
/**
*/
definition(
name: “Web Services Tutorial”,
namespace: “smartthings”,
author: “SmartThings”,
description: “web services tutorial”,
category: “”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
oauth: [displayName: "web services tutorial ", displayLink: “http://localhost:4567”])
preferences {
section (“Allow external service to control these things…”) {
input “switches”, “capability.switch”, multiple: true, required: true
}
}
mappings {
path(“/switches”) {
action: [
GET: “listSwitches”
]
}
path(“/switches/:command”) {
action: [
PUT: “updateSwitches”
]
}
}
// returns a list like
// [[name: “kitchen lamp”, value: “off”], [name: “bathroom”, value: “on”]]
def listSwitches() {
def resp = []
switches.each {
resp << [name: it.displayName, value: it.currentValue("switch")]
}
return resp
}
void updateSwitches() {
// use the built-in request object to get the command parameter
def command = params.command
if (command) {
// check that the switch supports the specified command
// If not, return an error using httpError, providing a HTTP status code.
switches.each {
if (!it.hasCommand(command)) {
httpError(501, "$command is not a valid command for all switches specified")
}
}
// all switches have the comand
// execute the command on all switches
// (note we can do this on the array - the command will be invoked on every element
switches."$command"()
}
}
def installed() {}
def updated() {}