[avmfritz] Added warning if temperature command cannot be converted to Celsius (#9778)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2021-01-13 23:32:42 +01:00
parent 78d8087f0d
commit c8698571ae
No known key found for this signature in database
GPG Key ID: E60BC5062C9F0695

View File

@ -344,8 +344,15 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
if (command instanceof DecimalType) {
temperature = normalizeCelsius(((DecimalType) command).toBigDecimal());
} else if (command instanceof QuantityType) {
temperature = normalizeCelsius(
((QuantityType<Temperature>) command).toUnit(SIUnits.CELSIUS).toBigDecimal());
@SuppressWarnings("unchecked")
QuantityType<Temperature> convertedCommand = ((QuantityType<Temperature>) command)
.toUnit(SIUnits.CELSIUS);
if (convertedCommand != null) {
temperature = normalizeCelsius(convertedCommand.toBigDecimal());
} else {
logger.warn("Unable to convert unit from '{}' to '{}'. Skipping command.",
((QuantityType<?>) command).getUnit(), SIUnits.CELSIUS);
}
} else if (command instanceof IncreaseDecreaseType) {
temperature = state.getHkr().getTsoll();
if (IncreaseDecreaseType.INCREASE.equals(command)) {