Skip to content

Commit f72337b

Browse files
committed
Fix temperature bug / immutable BigDecimal
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
1 parent a605169 commit f72337b

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -521,33 +521,31 @@ public void handleCommand(ChannelUID channelUID, Command command) {
521521
}
522522
break;
523523
case CHANNEL_SETTEMP:
524-
BigDecimal temperature = null;
524+
BigDecimal fritzTemperature = null;
525525
if (command instanceof DecimalType decimalCommand) {
526-
temperature = normalizeCelsius(decimalCommand.toBigDecimal());
526+
fritzTemperature = fromCelsius(normalizeCelsius(decimalCommand.toBigDecimal()));
527527
} else if (command instanceof QuantityType quantityCommand) {
528528
@SuppressWarnings("unchecked")
529529
QuantityType<Temperature> convertedCommand = ((QuantityType<Temperature>) command)
530530
.toUnit(SIUnits.CELSIUS);
531531
if (convertedCommand != null) {
532-
temperature = normalizeCelsius(convertedCommand.toBigDecimal());
532+
fritzTemperature = fromCelsius(normalizeCelsius(convertedCommand.toBigDecimal()));
533533
} else {
534534
logger.warn("Unable to convert unit from '{}' to '{}'. Skipping command.",
535535
quantityCommand.getUnit(), SIUnits.CELSIUS);
536536
}
537537
} else if (command instanceof IncreaseDecreaseType) {
538-
temperature = currentDevice.getHkr().getTsoll();
539-
if (IncreaseDecreaseType.INCREASE.equals(command)) {
540-
temperature.add(BigDecimal.ONE);
541-
} else {
542-
temperature.subtract(BigDecimal.ONE);
543-
}
538+
BigDecimal temperature = toCelsius(currentDevice.getHkr().getTsoll());
539+
temperature = IncreaseDecreaseType.INCREASE.equals(command) ? temperature.add(BigDecimal.ONE)
540+
: temperature.subtract(BigDecimal.ONE);
541+
fritzTemperature = fromCelsius(temperature);
544542
} else if (command instanceof OnOffType) {
545-
temperature = OnOffType.ON.equals(command) ? TEMP_FRITZ_ON : TEMP_FRITZ_OFF;
543+
fritzTemperature = OnOffType.ON.equals(command) ? TEMP_FRITZ_ON : TEMP_FRITZ_OFF;
546544
}
547-
if (temperature != null) {
548-
fritzBox.setSetTemp(ain, fromCelsius(temperature));
545+
if (fritzTemperature != null) {
546+
fritzBox.setSetTemp(ain, fritzTemperature);
549547
HeatingModel heatingModel = currentDevice.getHkr();
550-
heatingModel.setTsoll(temperature);
548+
heatingModel.setTsoll(fritzTemperature);
551549
updateState(CHANNEL_RADIATOR_MODE, new StringType(heatingModel.getRadiatorMode()));
552550
}
553551
break;

0 commit comments

Comments
 (0)