From 7e28fbb3c51c6d131e0ec81eb3d22611bd0d701e Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Wed, 13 Jan 2021 23:32:42 +0100 Subject: [PATCH] [avmfritz] Added warning if temperature command cannot be converted to Celsius (#9778) Signed-off-by: Christoph Weitkamp --- .../internal/handler/AVMFritzBaseThingHandler.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java index 789314560..967d43ebb 100644 --- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java +++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java @@ -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) command).toUnit(SIUnits.CELSIUS).toBigDecimal()); + @SuppressWarnings("unchecked") + QuantityType convertedCommand = ((QuantityType) 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)) {