diff --git a/bundles/org.openhab.binding.energidataservice/README.md b/bundles/org.openhab.binding.energidataservice/README.md index c28eb0524a008..a203dbabd1f19 100644 --- a/bundles/org.openhab.binding.energidataservice/README.md +++ b/bundles/org.openhab.binding.energidataservice/README.md @@ -47,15 +47,15 @@ It will not impact channels, see [Electricity Tax](#electricity-tax) for further ### Channel Group `electricity` -| Channel | Type | Description | Advanced | -|--------------------------|--------|----------------------------------------------------------------------------------------|----------| -| spot-price | Number | Current spot price in DKK or EUR per kWh | no | -| grid-tariff | Number | Current grid tariff in DKK per kWh. Only available when `gridCompanyGLN` is configured | no | -| system-tariff | Number | Current system tariff in DKK per kWh | no | -| transmission-grid-tariff | Number | Current transmission grid tariff in DKK per kWh | no | -| electricity-tax | Number | Current electricity tax in DKK per kWh | no | -| reduced-electricity-tax | Number | Current reduced electricity tax in DKK per kWh. For electric heating customers only | no | -| hourly-prices | String | JSON array with hourly prices from 24 hours ago and onward | yes | +| Channel | Type | Description | Advanced | +|--------------------------|--------------------|--------------------------------------------------------------------------------|----------| +| spot-price | Number:EnergyPrice | Spot price in DKK or EUR per kWh | no | +| grid-tariff | Number:EnergyPrice | Grid tariff in DKK per kWh. Only available when `gridCompanyGLN` is configured | no | +| system-tariff | Number:EnergyPrice | System tariff in DKK per kWh | no | +| transmission-grid-tariff | Number:EnergyPrice | Transmission grid tariff in DKK per kWh | no | +| electricity-tax | Number:EnergyPrice | Electricity tax in DKK per kWh | no | +| reduced-electricity-tax | Number:EnergyPrice | Reduced electricity tax in DKK per kWh. For electric heating customers only | no | +| hourly-prices | String | JSON array with hourly prices from 24 hours ago and onward | yes | _Please note:_ There is no channel providing the total price. Instead, create a group item with `SUM` as aggregate function and add the individual price items as children. 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 ca686821fb6b0..5f6ed20d78dbe 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 @@ -56,7 +56,8 @@ import org.openhab.binding.energidataservice.internal.retry.RetryPolicyFactory; import org.openhab.binding.energidataservice.internal.retry.RetryStrategy; import org.openhab.core.i18n.TimeZoneProvider; -import org.openhab.core.library.types.DecimalType; +import org.openhab.core.library.dimension.EnergyPrice; +import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -320,14 +321,19 @@ private void updateCurrentSpotPrice() { return; } BigDecimal spotPrice = cacheManager.getSpotPrice(); - updateState(CHANNEL_SPOT_PRICE, spotPrice != null ? new DecimalType(spotPrice) : UnDefType.UNDEF); + updateState(CHANNEL_SPOT_PRICE, + spotPrice != null ? getEnergyPrice(spotPrice, config.getCurrency()) : UnDefType.UNDEF); } private void updateCurrentTariff(String channelId, @Nullable BigDecimal tariff) { if (!isLinked(channelId)) { return; } - updateState(channelId, tariff != null ? new DecimalType(tariff) : UnDefType.UNDEF); + updateState(channelId, tariff != null ? getEnergyPrice(tariff, CURRENCY_DKK) : UnDefType.UNDEF); + } + + private QuantityType getEnergyPrice(BigDecimal price, Currency currency) { + return new QuantityType<>(price + " " + currency.getSymbol() + "/kWh"); } private void updateHourlyPrices() { @@ -367,7 +373,7 @@ private void updateTimeSeries() { for (Entry spotPrice : spotPrices) { Instant hourStart = spotPrice.getKey(); if (isLinked(CHANNEL_SPOT_PRICE)) { - spotPriceTimeSeries.add(hourStart, new DecimalType(spotPrice.getValue())); + spotPriceTimeSeries.add(hourStart, getEnergyPrice(spotPrice.getValue(), config.getCurrency())); } for (Map.Entry entry : datahubTimeSeriesMap.entrySet()) { DatahubTariff datahubTariff = entry.getKey(); @@ -378,7 +384,7 @@ private void updateTimeSeries() { BigDecimal tariff = cacheManager.getTariff(datahubTariff, hourStart); if (tariff != null) { TimeSeries timeSeries = entry.getValue(); - timeSeries.add(hourStart, new DecimalType(tariff)); + timeSeries.add(hourStart, getEnergyPrice(tariff, CURRENCY_DKK)); } } } diff --git a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-groups.xml b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-groups.xml index 83587c1e46a67..872bc9e3de561 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-groups.xml +++ b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-groups.xml @@ -10,27 +10,27 @@ - Current spot price in DKK or EUR per kWh. + Spot price in DKK or EUR per kWh. - Current grid tariff in DKK per kWh. + Grid tariff in DKK per kWh. - Current system tariff in DKK per kWh. + System tariff in DKK per kWh. - Current transmission grid tariff in DKK per kWh. + Transmission grid tariff in DKK per kWh. - Current electricity tax in DKK per kWh. + Electricity tax in DKK per kWh. - Current reduced electricity tax in DKK per kWh. For electric heating customers only. + Reduced electricity tax in DKK per kWh. For electric heating customers only. diff --git a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-types.xml index 70749213ba05d..eed37700b221a 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/channel-types.xml @@ -5,19 +5,19 @@ xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - Number + Number:EnergyPrice Spot price. Price - + - Number + Number:EnergyPrice Datahub price. Price - + diff --git a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/thing-service.xml b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/thing-service.xml index 805510a68eab8..6a7e97f9a8b72 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/thing-service.xml +++ b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/thing/thing-service.xml @@ -14,7 +14,7 @@ - 2 + 3 diff --git a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/update/instructions.xml index ef4dd6bd99184..ad8ed729915cd 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/update/instructions.xml +++ b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/update/instructions.xml @@ -28,6 +28,39 @@ + + + energidataservice:spot-price + + Spot price in DKK or EUR per kWh. + + + energidataservice:datahub-price + + Grid tariff in DKK per kWh. + + + energidataservice:datahub-price + + System tariff in DKK per kWh. + + + energidataservice:datahub-price + + Transmission grid tariff in DKK per kWh. + + + energidataservice:datahub-price + + Electricity tax in DKK per kWh. + + + energidataservice:datahub-price + + Reduced electricity tax in DKK per kWh. For electric heating customers only. + + +