2 * Example: Control a switch with a contact sensor
4 * Copyright 2015 Andrew Mager
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 switch with a contact sensor",
18 namespace: "com.smarthings.dev",
19 author: "Andrew Mager",
20 description: "Using a contact sensor, control a switch.",
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("Select Devices") {
28 input "contact", "capability.contactSensor", title: "Select a contact sensor", multiple: false
29 input "light", "capability.switch", title: "Select a light or outlet"
34 log.debug "Installed with settings: ${settings}"
39 log.debug "Updated with settings: ${settings}"
45 subscribe contact, "contact.open", openHandler
46 subscribe contact, "contact.closed", closedHandler
49 def openHandler(evt) {
50 log.debug "$evt.name: $evt.value"
54 def closedHandler(evt) {
55 log.debug "$evt.name: $evt.value"
59 // TODO: implement event handlers