Fixing bug in Mobile Presence class
[smartthings-infrastructure.git] / RelaySwitch / RelaySwitch.groovy
1 //Create a class for relay switch device
2 package RelaySwitch
3 import SmartThing.SmartThing
4
5 public class RelaySwitch extends SmartThing {
6         // id, label, and display name of the device
7         String id
8         String label
9         String displayName
10         // Maps from features to values
11         HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
12
13         RelaySwitch(Closure sendEvent, String id, String label, String displayName, String currentSwitch) {
14                 deviceValueSmartThing = deviceValuesMap
15                 idSmartThing = id
16                 labelSmartThing = label
17                 displayNameSmartThing = displayName
18                 sendEventSmartThings = sendEvent
19
20                 // Initialization
21                 this.id = id
22                 this.label = label
23                 this.displayName = displayName
24
25                 deviceValuesMap.put("switch", currentSwitch)
26         }
27
28         // Methods to set values
29         def on() {
30                 action("on", "switch")
31         }
32
33         def on(LinkedHashMap metaData) {
34                 on()
35         }
36
37         def off() {
38                 action("off", "switch")
39         }
40
41         def off(LinkedHashMap metaData) {
42                 off()
43         }
44 }