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