}
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);