Infrastructure compatible with swiches
[smartthings-infrastructure.git] / SmartThing / SmartThing.groovy
index 7b3b26efd42ac1c56b91df5f92dd3b35f39b2b3f..ec4907a79e9a795f86fb81d8853dfb83ccba950e 100644 (file)
@@ -26,8 +26,8 @@ public class SmartThing {
                                 sendEventSmartThings(eventDataMap)
                         }
                 } else if (deviceIntValueSmartThing.containsKey(name)) {
-                        if (!value.equals(deviceIntValueSmartThing.get(name))) {
-                                deviceIntValueSmartThing.put(name, value)
+                        if (!value.toInteger().equals(deviceIntValueSmartThing.get(name))) {
+                                deviceIntValueSmartThing.put(name, value.toInteger())
                                 println("the $name of the $displayNameSmartThing with id:$tmpID is triggered to $value!")
                                 sendEventSmartThings(eventDataMap)
                         }
@@ -50,7 +50,7 @@ public class SmartThing {
        }
 
        def sendCurrentValue() {
-               def evtTemp = [[name: labelSmartThing, value: deviceIntValueSmartThing.get(labelSmartThing), deviceId: idSmartThing, descriptionText: "",
+               def evtTemp = [[name: labelSmartThing, value: deviceIntValueSmartThing.get(labelSmartThing).toString(), deviceId: idSmartThing, descriptionText: "",
                                displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
                def init = Verify.getInt(0,1)
                def evtToSend = []
@@ -116,7 +116,7 @@ public class SmartThing {
                if (!deviceIntValueSmartThing.get(feature).equals(newValue)) {
                        deviceIntValueSmartThing.put(feature, newValue)
                        println("$feature of the $displayNameSmartThing with id:$idSmartThing is changed to $newValue!")
-                       sendEventSmartThings([name: feature, value: newValue, deviceId: idSmartThing, descriptionText: "",
+                       sendEventSmartThings([name: feature, value: newValue.toString(), deviceId: idSmartThing, descriptionText: "",
                                              displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -142,9 +142,9 @@ public class SmartThing {
        
        def currentValue(String deviceFeature) {
                if (deviceValueSmartThing.containsKey(deviceFeature)) {
-                       return deviceValueSmartThing.get(deviceFeature).toString()
+                       return deviceValueSmartThing.get(deviceFeature)
                } else if (deviceIntValueSmartThing.containsKey(deviceFeature)) {
-                       return deviceIntValueSmartThing.get(deviceFeature).getValue()   
+                       return deviceIntValueSmartThing.get(deviceFeature)      
                } else {
                        println("Wrong device feature is sent to this method!")
                }