From a533b191302c807904ca37633c57efce32c95c7b Mon Sep 17 00:00:00 2001 From: Martin Herbst Date: Mon, 7 Mar 2022 22:04:33 +0100 Subject: [PATCH] [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 --- .../homematic/internal/communicator/CcuGateway.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 + "\""; } -- 2.47.3