Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / Lock / Lock.groovy
index 1ceac32e84a3850693bbf0b25045d7430aef608e..50b96e45333667af85c1296b8b346f77411ec210 100644 (file)
@@ -4,17 +4,14 @@ import SmartThing.SmartThing
 
 public class Lock extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentLock = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-
-       Lock(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentLock) {
-               deviceValuesMap = deviceValueSmartThing
+       Lock(Closure sendEvent, String id, String label, String displayName, String currentLock) {
+               deviceValueSmartThing = deviceValuesMap 
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -24,14 +21,13 @@ public class Lock extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentLock = currentLock
 
                deviceValuesMap.put("lock", currentLock)
        }
 
        // Methods to set values
        def lock() {
-               action(currentLock, "locked")
+               action("locked", "lock")
        }
 
        def lock(LinkedHashMap metaData) {
@@ -39,26 +35,10 @@ public class Lock extends SmartThing {
        }
        
        def unlock() {
-               action(currentLock, "unlocked")
+               action("unlocked", "lock")
        }
 
        def unlock(LinkedHashMap metaData) {
                unlock()
        }
-
-       def action(StringBuilder variable, String newValue) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("Lock with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: "lock", value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentLock() {
-               return currentLock.toString()
-       }
-
 }