public class Event {
private String deviceId
- private Object value
+ private String value
private String linkText
private String displayName
private boolean displayed
private boolean physical
private def date
- Event(Object value, String name, String deviceId, String descriptionText, boolean displayed, String linkText, String displayName, boolean isStateChange, String unit, String data) {
+ Event(String value, String name, String deviceId, String descriptionText, boolean displayed, String linkText, String displayName, boolean isStateChange, String unit, String data) {
this.deviceId = deviceId
this.linkText = linkText
this.value = value
this.jsonData = new groovy.json.JsonSlurper().parseText(data)
this.displayed = displayed
if (["battery", "hue", "saturation", "energy", "level", "temperature", "heatingSetpoint", "coolingSetpoint", "thermostatSetpoint", "illuminance"].contains(name)) {
- this.integerValue = value
- this.doubleValue = value
+ int dot = value.indexOf('.')
+ if (dot != -1)
+ value = value.substring(0, dot)
+ this.integerValue = value.toInteger()
+ this.doubleValue = Double.parseDouble(value);
}
this.physical = true
this.date = new Date()
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)
}
}
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 = []
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"}'])
}
}