]> git.basschouten.com Git - openhab-addons.git/commitdiff
[avmfritz] Added warning if temperature command cannot be converted to Celsius (...
authorChristoph Weitkamp <github@christophweitkamp.de>
Wed, 13 Jan 2021 22:32:42 +0000 (23:32 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Jan 2021 22:32:42 +0000 (14:32 -0800)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java

index 7893145606485a0b728acf59b3fdcd11c37ea0db..967d43ebb50e9b2e5b7a2914d8c9ca0d6995a5cc 100644 (file)
@@ -367,8 +367,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)) {