]> git.basschouten.com Git - openhab-addons.git/commitdiff
[homematic] Prevent the use of exponential notation (#12436)
authorMartin Herbst <develop@mherbst.de>
Mon, 7 Mar 2022 21:04:33 +0000 (22:04 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Mar 2022 21:04:33 +0000 (22:04 +0100)
* Prevent the use of exponential notation

The CCU does not accept exponential notation in TCL scripts.

Fix #12301

Signed-off-by: Martin Herbst <develop@mherbst.de>
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/CcuGateway.java

index d1e636b50ae6967080adf712714d708e44f95f2e..8846b95798b60e61086dc65e7451766a466ab07f 100644 (file)
@@ -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 + "\"";
         }