mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Reduce currency unit work-around after core fix (#16217)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
3415397a83
commit
89803c1a19
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user