[siemensrds] Fix setting of target temperature (#17697)

Signed-off-by: AndrewFG <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green 2024-11-04 15:51:14 +00:00 committed by GitHub
parent 3fef5cc297
commit 5d20cba182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: {