From 9b6808bdc7c97bd9bead70e30cf72ca4d84869f8 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Fri, 5 Jan 2024 23:47:13 +0100 Subject: [PATCH] Reduce currency unit work-around after core fix Signed-off-by: Jacob Laursen --- .../internal/handler/EnergiDataServiceHandler.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/handler/EnergiDataServiceHandler.java b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/handler/EnergiDataServiceHandler.java index d5d0585a2a438..ee3534aa7a51d 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/handler/EnergiDataServiceHandler.java +++ b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/handler/EnergiDataServiceHandler.java @@ -340,17 +340,14 @@ private void updatePriceState(String channelID, @Nullable BigDecimal price, Curr } 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);