]> git.basschouten.com Git - openhab-addons.git/commitdiff
Reduce currency unit work-around after core fix (#16217)
authorJacob Laursen <jacob-github@vindvejr.dk>
Sat, 6 Jan 2024 17:19:55 +0000 (18:19 +0100)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2024 17:19:55 +0000 (18:19 +0100)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/handler/EnergiDataServiceHandler.java

index d5d0585a2a4384a1b7bde0e015e843278bb73540..ee3534aa7a51d411677ed19d710d5b2b41b385b9 100644 (file)
@@ -340,17 +340,14 @@ public class EnergiDataServiceHandler extends BaseThingHandler {
     }
 
     private State getEnergyPrice(BigDecimal price, Currency currency) {
-        Unit<?> unit = CurrencyUnits.getInstance().getUnit(currency.getCurrencyCode());
+        String currencyCode = currency.getCurrencyCode();
+        Unit<?> unit = CurrencyUnits.getInstance().getUnit(currencyCode);
         if (unit == null) {
             logger.trace("Currency {} is unknown, falling back to DecimalType", currency.getCurrencyCode());
             return new DecimalType(price);
         }
         try {
-            String currencyUnit = unit.getSymbol();
-            if (currencyUnit == null) {
-                currencyUnit = unit.getName();
-            }
-            return new QuantityType<>(price + " " + currencyUnit + "/kWh");
+            return new QuantityType<>(price + " " + currencyCode + "/kWh");
         } catch (IllegalArgumentException e) {
             logger.debug("Unable to create QuantityType, falling back to DecimalType", e);
             return new DecimalType(price);