mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-04 11:24:10 +01:00
Reduce currency unit work-around after core fix (#16217)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
9c6c475a1c
commit
6d36fa92e3
@ -340,17 +340,14 @@ public class EnergiDataServiceHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private State getEnergyPrice(BigDecimal price, Currency currency) {
|
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) {
|
if (unit == null) {
|
||||||
logger.trace("Currency {} is unknown, falling back to DecimalType", currency.getCurrencyCode());
|
logger.trace("Currency {} is unknown, falling back to DecimalType", currency.getCurrencyCode());
|
||||||
return new DecimalType(price);
|
return new DecimalType(price);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String currencyUnit = unit.getSymbol();
|
return new QuantityType<>(price + " " + currencyCode + "/kWh");
|
||||||
if (currencyUnit == null) {
|
|
||||||
currencyUnit = unit.getName();
|
|
||||||
}
|
|
||||||
return new QuantityType<>(price + " " + currencyUnit + "/kWh");
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.debug("Unable to create QuantityType, falling back to DecimalType", e);
|
logger.debug("Unable to create QuantityType, falling back to DecimalType", e);
|
||||||
return new DecimalType(price);
|
return new DecimalType(price);
|
||||||
|
Loading…
Reference in New Issue
Block a user