From 0af9236b82ff703474365b48cf846db5df4dc148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Tue, 25 Jul 2023 19:06:38 +0200 Subject: [PATCH] [transform.math] Fix missing unit when result is 0 (#507) * Code modification proposal following issue #506 Signed-off-by: clinique --- .../math/internal/AbstractMathTransformationService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bundles/org.smarthomej.transform.math/src/main/java/org/smarthomej/transform/math/internal/AbstractMathTransformationService.java b/bundles/org.smarthomej.transform.math/src/main/java/org/smarthomej/transform/math/internal/AbstractMathTransformationService.java index 4c2019b217..c71df530ab 100644 --- a/bundles/org.smarthomej.transform.math/src/main/java/org/smarthomej/transform/math/internal/AbstractMathTransformationService.java +++ b/bundles/org.smarthomej.transform.math/src/main/java/org/smarthomej/transform/math/internal/AbstractMathTransformationService.java @@ -12,8 +12,6 @@ */ package org.smarthomej.transform.math.internal; -import java.math.BigDecimal; - import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.library.types.QuantityType; @@ -56,7 +54,7 @@ abstract class AbstractMathTransformationService implements TransformationServic } try { QuantityType result = performCalculation(source, value); - return BigDecimal.ZERO.compareTo(result.toBigDecimal()) == 0 ? "0" : result.toString(); + return performCalculation(source, value).toString(); } catch (IllegalArgumentException e) { throw new TransformationException("ArithmeticException: " + e.getMessage()); }