[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 <develop@mherbst.de>
This commit is contained in:
Martin Herbst 2022-03-07 22:04:33 +01:00 committed by GitHub
parent 0e0b9afe08
commit a533b19130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View 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 + "\"";
}