Infrastructure compatible with swiches
[smartthings-infrastructure.git] / SmartThing / SmartThing.groovy
index b869773..ec4907a 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"}'])
                }
        }