X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=blobdiff_plain;f=Event%2FEvent.groovy;h=7e834345ac2da8b4b09f47427e99c6f8e806cf4f;hp=60d7276f7ce4ad7e46452daaad4d70a198e81341;hb=a506caeba94b4c035e0c47f29017f07773e3f318;hpb=6b033926fc678d37f4509f6f86a6264803ef904f diff --git a/Event/Event.groovy b/Event/Event.groovy index 60d7276..7e83434 100644 --- a/Event/Event.groovy +++ b/Event/Event.groovy @@ -1,5 +1,6 @@ //Create a class for Events package Event +import groovy.json.JsonSlurper public class Event { private String deviceId @@ -12,10 +13,13 @@ public class Event { private boolean isStateChange private String unit private String data + 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 Event(String value, String name, String deviceId, String descriptionText, boolean displayed, String linkText, String displayName, boolean isStateChange, String unit, String data) { this.deviceId = deviceId @@ -27,10 +31,13 @@ public class Event { this.isStateChange = isStateChange this.unit = unit this.data = data + this.jsonData = new groovy.json.JsonSlurper().parseText(data) this.displayed = displayed if (integerValues.contains(name)) { this.integerValue = value.toInteger() this.doubleValue = Double.parseDouble(value); } + this.physical = true + this.date = new Date() } }