From e7dda8ffbd739ae916d8fdc27abdf0c18af399fc Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Mon, 4 Nov 2024 15:51:14 +0000 Subject: [PATCH] [siemensrds] Fix setting of target temperature (#17697) Signed-off-by: AndrewFG Signed-off-by: Ciprian Pascu --- .../binding/siemensrds/internal/RdsHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/internal/RdsHandler.java b/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/internal/RdsHandler.java index df27dc5cb71..d5d747cabc8 100644 --- a/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/internal/RdsHandler.java +++ b/bundles/org.openhab.binding.siemensrds/src/main/java/org/openhab/binding/siemensrds/internal/RdsHandler.java @@ -24,6 +24,7 @@ import javax.measure.Unit; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.siemensrds.points.BasePoint; +import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; @@ -312,16 +313,21 @@ public class RdsHandler extends BaseThingHandler { if (channelId.equals(channel.id)) { switch (channel.id) { case CHA_TARGET_TEMP: { - Command doCommand = command; + double targetTemperature = Double.NaN; if (command instanceof QuantityType quantityCommand) { Unit unit = points.getPointByClass(channel.clazz).getUnit(); QuantityType temp = quantityCommand.toUnit(unit); if (temp != null) { - doCommand = temp; + targetTemperature = temp.doubleValue(); } + } else if (command instanceof DecimalType decimalCommand) { + targetTemperature = decimalCommand.doubleValue(); + } + if (targetTemperature != Double.NaN) { + points.setValue(apiKey, token, channel.clazz, + String.format("%.1f", Math.round(targetTemperature * 2) / 2.0)); + debouncer.initialize(channelId); } - points.setValue(apiKey, token, channel.clazz, doCommand.format("%s")); - debouncer.initialize(channelId); break; } case CHA_STAT_AUTO_MODE: {