2 * Example: Control a switch with a contact sensor
4 * Copyright 2015 SmartThings
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
17 name: "Example: Control a device with an API call",
18 namespace: "com.smarthings.developers",
19 author: "Andrew Mager & Kris Schaller",
20 description: "Make an HTTP request to a SmartApp to control devices.",
22 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
23 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
27 section(title: "Select Devices") {
28 input "light", "capability.switch", title: "Select a light or outlet", required: true, multiple:false
32 // Since the SmartApp doesn't have any dependencies when it's installed or updated,
33 // we don't need to worry about those states.
38 // This block defines an endpoint, and which functions will fire depending on which type
39 // of HTTP request you send
41 // The path is appended to the endpoint to make requests
43 // These actions link HTTP verbs to specific callback functions in your SmartApp
45 GET: "getSwitch", // "When an HTTP GET request is received, run getSwitch()"
54 // This returns the current state of the switch in JSON
55 return light.currentState("switch")
59 switch(request.JSON.value) {