From: Martin Herbst Date: Mon, 7 Mar 2022 21:04:33 +0000 (+0100) Subject: [homematic] Prevent the use of exponential notation (#12436) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=a533b191302c807904ca37633c57efce32c95c7b;p=openhab-addons.git [homematic] Prevent the use of exponential notation (#12436) * Prevent the use of exponential notation The CCU does not accept exponential notation in TCL scripts. Fix #12301 Signed-off-by: Martin Herbst --- diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/CcuGateway.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/CcuGateway.java index d1e636b50a..8846b95798 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/CcuGateway.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/CcuGateway.java @@ -14,6 +14,7 @@ package org.openhab.binding.homematic.internal.communicator; import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -149,7 +150,12 @@ public class CcuGateway extends AbstractHomematicGateway { @Override protected void setVariable(HmDatapoint dp, Object value) throws IOException { - String strValue = Objects.toString(value, "").replace("\"", "\\\""); + String strValue; + if (value instanceof Double) { + strValue = new BigDecimal((Double) value).stripTrailingZeros().toPlainString(); + } else { + strValue = Objects.toString(value, "").replace("\"", "\\\""); + } if (dp.isStringType()) { strValue = "\"" + strValue + "\""; }