Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[siemensrds] Fix setting of target temperature #17697

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -312,16 +313,21 @@ private synchronized void doHandleCommand(String channelId, Command command) {
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: {
Expand Down