From 2cce90f83d7053491a3ce086f99d76e8c97d6735 Mon Sep 17 00:00:00 2001 From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Fri, 4 Mar 2022 03:49:49 +1000 Subject: [PATCH] [fronius] Fix DecimalType constructor change (#12371) Signed-off-by: Jimmy Tanagra --- .../internal/handler/FroniusBaseThingHandler.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBaseThingHandler.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBaseThingHandler.java index 974d45bd1a3..f0caee8cf51 100644 --- a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBaseThingHandler.java +++ b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusBaseThingHandler.java @@ -12,8 +12,6 @@ */ package org.openhab.binding.fronius.internal.handler; -import java.math.BigDecimal; - import org.eclipse.jdt.annotation.NonNull; import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration; import org.openhab.binding.fronius.internal.FroniusCommunicationException; @@ -109,18 +107,14 @@ public abstract class FroniusBaseThingHandler extends BaseThingHandler { } State state = null; - if (value instanceof BigDecimal) { - state = new DecimalType((BigDecimal) value); - } else if (value instanceof Integer) { - state = new DecimalType(BigDecimal.valueOf(((Integer) value).longValue())); - } else if (value instanceof Double) { - state = new DecimalType((double) value); + if (value instanceof QuantityType) { + state = (QuantityType) value; + } else if (value instanceof Number) { + state = new DecimalType((Number) value); } else if (value instanceof ValueUnit) { state = new DecimalType(((ValueUnit) value).getValue()); } else if (value instanceof String) { state = new StringType((String) value); - } else if (value instanceof QuantityType) { - state = (QuantityType) value; } else { logger.warn("Update channel {}: Unsupported value type {}", channelId, value.getClass().getSimpleName()); }