Fixing value field type in events
[smartthings-infrastructure.git] / Lock / Locks.groovy
1 //Create a class for lock device
2 package Lock
3 import SmartThing.SmartThings
4
5 public class Locks extends SmartThings {
6         List locks = new ArrayList()
7
8         Locks(Closure sendEvent, boolean init) {
9                 // Only initialize one time since we only have one device for each capability
10                 locks = smartThings
11
12                 // Initialization
13                 String id = "lockID0"
14                 String label = "lock"
15                 String displayName = "lock"
16                 String lock
17
18                 if (init)
19                         lock = "locked"
20                 else
21                         lock = "unlocked"
22
23                 locks.add(new Lock(sendEvent, id, label, displayName, lock))
24         }
25
26         // Methods to set values
27         def lock() {
28                 locks[0].lock()
29         }
30
31         def lock(LinkedHashMap metaData) {
32                 lock()
33         }
34
35         def unlock() {
36                 locks[0].unlock()
37         }
38
39
40         def unlock(LinkedHashMap metaData) {
41                 unlock()
42         }
43 }
44