Infrastructure compatible with swiches
[smartthings-infrastructure.git] / Event / Event.groovy
index 7e834345ac2da8b4b09f47427e99c6f8e806cf4f..83ba658355e5d838fa72c10b92f1c184b57bba5b 100644 (file)
@@ -16,8 +16,6 @@ public class Event {
        private jsonData
        private int integerValue
        private double doubleValue
-       private List integerValues = ["battery", "hue", "saturation", "energy", "level", "temperature", 
-                                     "heatingSetpoint", "coolingSetpoint", "thermostatSetpoint", "illuminance"]
        private boolean physical
        private def date
        
@@ -33,9 +31,12 @@ public class Event {
                this.data = data
                this.jsonData = new groovy.json.JsonSlurper().parseText(data)
                this.displayed = displayed
-               if (integerValues.contains(name)) {
+               if (["battery", "hue", "saturation", "energy", "level", "temperature", "heatingSetpoint", "coolingSetpoint", "thermostatSetpoint", "illuminance"].contains(name)) {
+                       int dot = value.indexOf('.')
+                       if (dot != -1)
+                       value = value.substring(0, dot)
                        this.integerValue = value.toInteger()
-                       this.doubleValue = Double.parseDouble(value);           
+                       this.doubleValue = Double.parseDouble(value);
                }
                this.physical = true
                this.date = new Date()