4 * Copyright 2015 Jesse Silverberg
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: "My Light Toggle",
19 author: "Jesse Silverberg",
20 description: "Toggle lights on/off with a motion sensor",
21 category: "Convenience",
22 iconUrl: "https://www.dropbox.com/s/6kxtd2v5reggonq/lightswitch.gif?raw=1",
23 iconX2Url: "https://www.dropbox.com/s/6kxtd2v5reggonq/lightswitch.gif?raw=1",
24 iconX3Url: "https://www.dropbox.com/s/6kxtd2v5reggonq/lightswitch.gif?raw=1")
28 section("When this sensor detects motion...") {
29 input "motionToggler", "capability.motionSensor", title: "Motion Here", required: true, multiple: false
32 section("Master switch for the toggle reference...") {
33 input "masterToggle", "capability.switch", title: "Reference switch", required: true, multiple: false
36 section("Toggle lights...") {
37 input "switchesToToggle", "capability.switch", title: "These go on/off", required: true, multiple: true
42 log.debug "Installed with settings: ${settings}"
48 log.debug "Updated with settings: ${settings}"
55 subscribe(motionToggler, "motion", toggleSwitches)
59 def toggleSwitches(evt) {
60 log.debug "$evt.value"
62 if (evt.value == "active" && masterToggle.currentSwitch == "off") {
63 // for (thisSwitch in switchesToToggle) {
64 // log.debug "$thisSwitch.label"
68 } else if (evt.value == "active" && masterToggle.currentSwitch == "on") {
69 // for (thisSwitch in switchesToToggle) {
70 // log.debug "$thisSwitch.label"
72 switchesToToggle.off()