2 * Copyright 2015 SmartThings
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
10 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
11 * for the specific language governing permissions and limitations under the License.
20 name: "The Big Switch",
21 namespace: "smartthings",
22 author: "SmartThings",
23 description: "Turns on, off and dim a collection of lights based on the state of a specific switch.",
24 category: "Convenience",
25 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png",
26 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png"
30 section("When this switch is turned on, off or dimmed") {
31 input "master", "capability.switch", title: "Where?"
33 section("Turn on or off all of these switches as well") {
34 input "switches", "capability.switch", multiple: true, required: false
36 section("And turn off but not on all of these switches") {
37 input "offSwitches", "capability.switch", multiple: true, required: false
39 section("And turn on but not off all of these switches") {
40 input "onSwitches", "capability.switch", multiple: true, required: false
42 section("And Dim these switches") {
43 input "dimSwitches", "capability.switchLevel", multiple: true, required: false
49 subscribe(master, "switch.on", onHandler)
50 subscribe(master, "switch.off", offHandler)
51 subscribe(master, "level", dimHandler)
57 subscribe(master, "switch.on", onHandler)
58 subscribe(master, "switch.off", offHandler)
59 subscribe(master, "level", dimHandler)
68 log.debug onSwitches1()
74 log.debug offSwitches1()
79 log.debug "Dim level: $evt.value"
80 dimSwitches?.setLevel(evt.value)
83 private onSwitches1() {
84 if(switches && onSwitches) { (switches).findAll{it} + (onSwitches).findAll{it} }
85 else if(switches) { (switches).findAll{it} }
86 else { (onSwitches).findAll{it} }
89 private offSwitches1() {
90 if(switches && offSwitches) { (switches).findAll{it} + (offSwitches).findAll{it} }
91 else if(switches) { (switches).findAll{it} }
92 else { (offSwitches).findAll{it} }