Skip to content

Commit

Permalink
[transform.math] Fix missing unit when result is 0 (#507)
Browse files Browse the repository at this point in the history
* Code modification proposal following issue #506

Signed-off-by: clinique <[email protected]>
  • Loading branch information
clinique committed Jul 25, 2023
1 parent c41b8ef commit 0af9236
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 0af9236

Please sign in to comment.