Fixing bug in Mobile Presence class
[smartthings-infrastructure.git] / Switch / Switches.groovy
1 //Create a class for switch device
2 package Switch
3 import SmartThing.SmartThings
4
5 public class Switches extends SmartThings {
6         List switches = new ArrayList()
7
8         Switches(Closure sendEvent, boolean init) {
9                 switches = smartThings
10
11                 // Initialization
12                 String id = "switchID0"
13                 String label = "switch"
14                 String displayName = "switch"
15                 String currentSwitch
16
17                 if (init)
18                         currentSwitch = "off"
19                 else
20                         currentSwitch = "on"
21
22                 switches.add(new Switch(sendEvent, id, label, displayName, currentSwitch))
23         }
24
25         // Methods to set values
26         def on() {
27                 switches[0].on()
28         }
29
30         def on(LinkedHashMap metaData) {
31                 on()
32         }
33
34         def off() {
35                 switches[0].off()
36         }
37
38         def off(LinkedHashMap metaData) {
39                 off()
40         }
41 }