Infrastructure compatible with swiches
[smartthings-infrastructure.git] / SmartThing / SmartThing.groovy
index b869773031db6367270e65edbc88d3291137f6a9..ec4907a79e9a795f86fb81d8853dfb83ccba950e 100644 (file)
@@ -26,8 +26,8 @@ public class SmartThing {
                                 sendEventSmartThings(eventDataMap)
                         }
                 } else if (deviceIntValueSmartThing.containsKey(name)) {
                                 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)
                         }
                                 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 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 = []
                                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!")
                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"}'])
                }
        }
                                              displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }