From 9b1553c33369040465f62abc68f8cbdca403248a Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 23 Nov 2023 19:36:30 +0100 Subject: [PATCH] Rename channels net-tariff and transmission-net-tariff (#15938) Signed-off-by: Jacob Laursen --- .../README.md | 68 +++++++++---------- .../internal/DatahubTariff.java | 6 +- .../EnergiDataServiceBindingConstants.java | 14 ++-- .../action/EnergiDataServiceActions.java | 6 +- .../api/DatahubTariffFilterFactory.java | 12 ++-- .../handler/EnergiDataServiceHandler.java | 32 +++++---- .../OH-INF/i18n/energidataservice.properties | 8 +-- .../resources/OH-INF/thing/channel-groups.xml | 14 ++-- .../resources/OH-INF/thing/thing-service.xml | 2 +- .../resources/OH-INF/update/instructions.xml | 15 ++++ .../action/EnergiDataServiceActionsTest.java | 34 +++++----- .../{NetTariffs.json => GridTariffs.json} | 0 ...iffs.json => TransmissionGridTariffs.json} | 0 13 files changed, 114 insertions(+), 97 deletions(-) rename bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/{NetTariffs.json => GridTariffs.json} (100%) rename bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/{TransmissionNetTariffs.json => TransmissionGridTariffs.json} (100%) diff --git a/bundles/org.openhab.binding.energidataservice/README.md b/bundles/org.openhab.binding.energidataservice/README.md index cf9972e47d6..c28eb0524a0 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 | -| net-tariff | Number | Current net tariff in DKK per kWh. Only available when `gridCompanyGLN` is configured | no | -| system-tariff | Number | Current system 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 | -| transmission-net-tariff | Number | Current transmission net tariff in DKK per kWh | no | -| hourly-prices | String | JSON array with hourly prices from 24 hours ago and onward | yes | +| 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 | _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. @@ -82,13 +82,13 @@ The recommended persistence strategy is `forecast`, as it ensures a clean histor Prices from the past 24 hours and all forthcoming prices will be stored. Any changes that impact published prices (e.g. selecting or deselecting VAT Profile) will result in the replacement of persisted prices within this period. -#### Net Tariff +#### Grid Tariff -Discounts are automatically taken into account for channel `net-tariff` so that it represents the actual price. +Discounts are automatically taken into account for channel `grid-tariff` so that it represents the actual price. The tariffs are downloaded using pre-configured filters for the different [Grid Company GLN's](#global-location-number-of-the-grid-company). If your company is not in the list, or the filters are not working, they can be manually overridden. -To override filters, the channel `net-tariff` has the following configuration parameters: +To override filters, the channel `grid-tariff` has the following configuration parameters: | Name | Type | Description | Default | Required | Advanced | |-----------------|---------|----------------------------------------------------------------------------------------------------------------------------------|---------|----------|----------| @@ -145,21 +145,21 @@ The format of the `hourly-prices` JSON array is as follows: "hourStart": "2023-09-19T18:00:00Z", "spotPrice": 0.0, "spotPriceCurrency": "DKK", - "netTariff": 0.0, + "gridTariff": 0.0, "systemTariff": 0.054, + "transmissionGridTariff": 0.058, "electricityTax": 0.697, - "reducedElectricityTax": 0.008, - "transmissionNetTariff": 0.058 + "reducedElectricityTax": 0.008 }, { "hourStart": "2023-09-19T19:00:00Z", "spotPrice": -0.00052, "spotPriceCurrency": "DKK", - "netTariff": 0.0, + "gridTariff": 0.0, "systemTariff": 0.054, + "transmissionGridTariff": 0.058, "electricityTax": 0.697, - "reducedElectricityTax": 0.008, - "transmissionNetTariff": 0.058 + "reducedElectricityTax": 0.008 } ] ``` @@ -334,14 +334,14 @@ var price = actions.calculatePrice(now.toInstant(), now.plusHours(4).toInstant, The parameter `priceComponents` is a case-insensitive comma-separated list of price components to include in the returned hourly prices. These components can be requested: -| Price component | Description | -|-----------------------|-------------------------| -| SpotPrice | Spot price | -| NetTariff | Net tariff | -| SystemTariff | System tariff | -| ElectricityTax | Electricity tax | -| ReducedElectricityTax | Reduced electricity tax | -| TransmissionNetTariff | Transmission net tariff | +| Price component | Description | +|------------------------|-------------------------| +| SpotPrice | Spot price | +| GridTariff | Grid tariff | +| SystemTariff | System tariff | +| TransmissionGridTariff | Transmission grid tariff | +| ElectricityTax | Electricity tax | +| ReducedElectricityTax | Reduced electricity tax | Using `null` as parameter returns the total prices including all price components. If **Reduced Electricity Tax** is set in Thing configuration, `ElectricityTax` will be excluded, otherwise `ReducedElectricityTax`. @@ -350,7 +350,7 @@ This logic ensures consistent and comparable results not affected by artifical c Example: ```javascript -var priceMap = actions.getPrices("SpotPrice,NetTariff") +var priceMap = actions.getPrices("SpotPrice,GridTariff") ``` ## Full Example @@ -360,7 +360,7 @@ var priceMap = actions.getPrices("SpotPrice,NetTariff") ```java Thing energidataservice:service:energidataservice "Energi Data Service" [ priceArea="DK1", currencyCode="DKK", gridCompanyGLN="5790001089030" ] { Channels: - Number : electricity#net-tariff [ chargeTypeCodes="CD,CD R", start="StartOfYear" ] + Number : electricity#grid-tariff [ chargeTypeCodes="CD,CD R", start="StartOfYear" ] } ``` @@ -369,10 +369,10 @@ Thing energidataservice:service:energidataservice "Energi Data Service" [ priceA ```java Group:Number:SUM TotalPrice "Current Total Price" Number SpotPrice "Current Spot Price" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#spot-price" [profile="transform:VAT"] } -Number NetTariff "Current Net Tariff" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#net-tariff" [profile="transform:VAT"] } +Number GridTariff "Current Grid Tariff" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#grid-tariff" [profile="transform:VAT"] } Number SystemTariff "Current System Tariff" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#system-tariff" [profile="transform:VAT"] } +Number TransmissionGridTariff "Current Transmission Grid Tariff" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#transmission-grid-tariff" [profile="transform:VAT"] } Number ElectricityTax "Current Electricity Tax" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#electricity-tax" [profile="transform:VAT"] } -Number TransmissionNetTariff "Current Transmission Tariff" (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#transmission-net-tariff" [profile="transform:VAT"] } String HourlyPrices "Hourly Prices" { channel="energidataservice:service:energidataservice:electricity#hourly-prices" } ``` @@ -394,8 +394,8 @@ var priceMap = actions.getPrices(null) var hourStart = now.toInstant().truncatedTo(ChronoUnit.HOURS) logInfo("Current total price excl. VAT", priceMap.get(hourStart).toString) -var priceMap = actions.getPrices("SpotPrice,NetTariff"); -logInfo("Current spot price + net tariff excl. VAT", priceMap.get(hourStart).toString) +var priceMap = actions.getPrices("SpotPrice,GridTariff"); +logInfo("Current spot price + grid tariff excl. VAT", priceMap.get(hourStart).toString) var price = actions.calculatePrice(Instant.now, now.plusHours(1).toInstant, 150 | W) logInfo("Total price for using 150 W for the next hour", price.toString) @@ -457,10 +457,10 @@ utils.javaMapToJsMap(edsActions.getPrices()).forEach((value, key) => { var hourStart = time.Instant.now().truncatedTo(time.ChronoUnit.HOURS); console.log("Current total price excl. VAT: " + priceMap.get(hourStart.toString())); -utils.javaMapToJsMap(edsActions.getPrices("SpotPrice,NetTariff")).forEach((value, key) => { +utils.javaMapToJsMap(edsActions.getPrices("SpotPrice,GridTariff")).forEach((value, key) => { priceMap.set(key.toString(), value); }); -console.log("Current spot price + net tariff excl. VAT: " + priceMap.get(hourStart.toString())); +console.log("Current spot price + grid tariff excl. VAT: " + priceMap.get(hourStart.toString())); var price = edsActions.calculatePrice(time.Instant.now(), time.Instant.now().plusSeconds(3600), Quantity("150 W")); console.log("Total price for using 150 W for the next hour: " + price.toString()); diff --git a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/DatahubTariff.java b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/DatahubTariff.java index b1e360f53c6..f04dc6146a9 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/DatahubTariff.java +++ b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/DatahubTariff.java @@ -23,11 +23,11 @@ import org.eclipse.jdt.annotation.NonNullByDefault; */ @NonNullByDefault public enum DatahubTariff { - NET_TARIFF(CHANNEL_NET_TARIFF), + GRID_TARIFF(CHANNEL_GRID_TARIFF), SYSTEM_TARIFF(CHANNEL_SYSTEM_TARIFF), + TRANSMISSION_GRID_TARIFF(CHANNEL_TRANSMISSION_GRID_TARIFF), ELECTRICITY_TAX(CHANNEL_ELECTRICITY_TAX), - REDUCED_ELECTRICITY_TAX(CHANNEL_REDUCED_ELECTRICITY_TAX), - TRANSMISSION_NET_TARIFF(CHANNEL_TRANSMISSION_NET_TARIFF); + REDUCED_ELECTRICITY_TAX(CHANNEL_REDUCED_ELECTRICITY_TAX); String channelId; diff --git a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/EnergiDataServiceBindingConstants.java b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/EnergiDataServiceBindingConstants.java index 210b133adb0..ccc81cb2d93 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/EnergiDataServiceBindingConstants.java +++ b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/EnergiDataServiceBindingConstants.java @@ -42,22 +42,22 @@ public class EnergiDataServiceBindingConstants { // List of all Channel ids public static final String CHANNEL_SPOT_PRICE = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + "spot-price"; - public static final String CHANNEL_NET_TARIFF = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR - + "net-tariff"; + public static final String CHANNEL_GRID_TARIFF = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + + "grid-tariff"; public static final String CHANNEL_SYSTEM_TARIFF = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + "system-tariff"; public static final String CHANNEL_ELECTRICITY_TAX = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + "electricity-tax"; public static final String CHANNEL_REDUCED_ELECTRICITY_TAX = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + "reduced-electricity-tax"; - public static final String CHANNEL_TRANSMISSION_NET_TARIFF = CHANNEL_GROUP_ELECTRICITY - + ChannelUID.CHANNEL_GROUP_SEPARATOR + "transmission-net-tariff"; + public static final String CHANNEL_TRANSMISSION_GRID_TARIFF = CHANNEL_GROUP_ELECTRICITY + + ChannelUID.CHANNEL_GROUP_SEPARATOR + "transmission-grid-tariff"; public static final String CHANNEL_HOURLY_PRICES = CHANNEL_GROUP_ELECTRICITY + ChannelUID.CHANNEL_GROUP_SEPARATOR + "hourly-prices"; - public static final Set ELECTRICITY_CHANNELS = Set.of(CHANNEL_SPOT_PRICE, CHANNEL_NET_TARIFF, - CHANNEL_SYSTEM_TARIFF, CHANNEL_ELECTRICITY_TAX, CHANNEL_REDUCED_ELECTRICITY_TAX, - CHANNEL_TRANSMISSION_NET_TARIFF, CHANNEL_HOURLY_PRICES); + public static final Set ELECTRICITY_CHANNELS = Set.of(CHANNEL_SPOT_PRICE, CHANNEL_GRID_TARIFF, + CHANNEL_SYSTEM_TARIFF, CHANNEL_TRANSMISSION_GRID_TARIFF, CHANNEL_ELECTRICITY_TAX, + CHANNEL_REDUCED_ELECTRICITY_TAX, CHANNEL_HOURLY_PRICES); // List of all properties public static final String PROPERTY_REMAINING_CALLS = "remainingCalls"; diff --git a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java index 9e8b307597b..de4f8385a22 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java +++ b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java @@ -63,11 +63,11 @@ public class EnergiDataServiceActions implements ThingActions { private enum PriceComponent { SPOT_PRICE("spotprice", null), - NET_TARIFF("nettariff", DatahubTariff.NET_TARIFF), + GRID_TARIFF("gridtariff", DatahubTariff.GRID_TARIFF), SYSTEM_TARIFF("systemtariff", DatahubTariff.SYSTEM_TARIFF), + TRANSMISSION_GRID_TARIFF("transmissiongridtariff", DatahubTariff.TRANSMISSION_GRID_TARIFF), ELECTRICITY_TAX("electricitytax", DatahubTariff.ELECTRICITY_TAX), - REDUCED_ELECTRICITY_TAX("reducedelectricitytax", DatahubTariff.REDUCED_ELECTRICITY_TAX), - TRANSMISSION_NET_TARIFF("transmissionnettariff", DatahubTariff.TRANSMISSION_NET_TARIFF); + REDUCED_ELECTRICITY_TAX("reducedelectricitytax", DatahubTariff.REDUCED_ELECTRICITY_TAX); private static final Map NAME_MAP = Stream.of(values()) .collect(Collectors.toMap(PriceComponent::toString, Function.identity())); diff --git a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/api/DatahubTariffFilterFactory.java b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/api/DatahubTariffFilterFactory.java index 07a248939d7..63de9d63802 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/api/DatahubTariffFilterFactory.java +++ b/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/api/DatahubTariffFilterFactory.java @@ -71,7 +71,7 @@ public class DatahubTariffFilterFactory { public static final LocalDate RADIUS_CUTOFF_DATE = LocalDate.of(2023, 1, 1); public static final LocalDate KONSTANT_CUTOFF_DATE = LocalDate.of(2023, 2, 1); - public static DatahubTariffFilter getNetTariffByGLN(String globalLocationNumber) { + public static DatahubTariffFilter getGridTariffByGLN(String globalLocationNumber) { switch (globalLocationNumber) { case GLN_AAL_ELNET: return new DatahubTariffFilter(Set.of(ChargeTypeCode.of("AAL-NT-05"), ChargeTypeCode.of("AAL-NTR05")), @@ -167,6 +167,11 @@ public class DatahubTariffFilterFactory { DateQueryParameter.of(ENERGINET_CUTOFF_DATE)); } + public static DatahubTariffFilter getTransmissionGridTariff() { + return new DatahubTariffFilter(Set.of(), Set.of(NOTE_TRANSMISSION_NET_TARIFF), + DateQueryParameter.of(ENERGINET_CUTOFF_DATE)); + } + public static DatahubTariffFilter getElectricityTax() { return new DatahubTariffFilter(Set.of(), Set.of(NOTE_ELECTRICITY_TAX), DateQueryParameter.of(ENERGINET_CUTOFF_DATE)); @@ -176,9 +181,4 @@ public class DatahubTariffFilterFactory { return new DatahubTariffFilter(Set.of(), Set.of(NOTE_REDUCED_ELECTRICITY_TAX), DateQueryParameter.of(LocalDate.of(2021, 2, 1))); } - - public static DatahubTariffFilter getTransmissionNetTariff() { - return new DatahubTariffFilter(Set.of(), Set.of(NOTE_TRANSMISSION_NET_TARIFF), - DateQueryParameter.of(ENERGINET_CUTOFF_DATE)); - } } 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 2a71212972c..ca686821fb6 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 @@ -95,8 +95,9 @@ public class EnergiDataServiceHandler extends BaseThingHandler { private @Nullable ScheduledFuture priceUpdateFuture; private record Price(String hourStart, BigDecimal spotPrice, String spotPriceCurrency, - @Nullable BigDecimal netTariff, @Nullable BigDecimal systemTariff, @Nullable BigDecimal electricityTax, - @Nullable BigDecimal reducedElectricityTax, @Nullable BigDecimal transmissionNetTariff) { + @Nullable BigDecimal gridTariff, @Nullable BigDecimal systemTariff, + @Nullable BigDecimal transmissionGridTariff, @Nullable BigDecimal electricityTax, + @Nullable BigDecimal reducedElectricityTax) { } public EnergiDataServiceHandler(Thing thing, HttpClient httpClient, TimeZoneProvider timeZoneProvider) { @@ -236,7 +237,7 @@ public class EnergiDataServiceHandler extends BaseThingHandler { private void downloadTariffs(DatahubTariff datahubTariff) throws InterruptedException, DataServiceException { GlobalLocationNumber globalLocationNumber = switch (datahubTariff) { - case NET_TARIFF -> config.getGridCompanyGLN(); + case GRID_TARIFF -> config.getGridCompanyGLN(); default -> config.getEnerginetGLN(); }; if (globalLocationNumber.isEmpty()) { @@ -247,11 +248,11 @@ public class EnergiDataServiceHandler extends BaseThingHandler { cacheManager.updateTariffs(datahubTariff); } else { DatahubTariffFilter filter = switch (datahubTariff) { - case NET_TARIFF -> getNetTariffFilter(); + case GRID_TARIFF -> getGridTariffFilter(); case SYSTEM_TARIFF -> DatahubTariffFilterFactory.getSystemTariff(); + case TRANSMISSION_GRID_TARIFF -> DatahubTariffFilterFactory.getTransmissionGridTariff(); case ELECTRICITY_TAX -> DatahubTariffFilterFactory.getElectricityTax(); case REDUCED_ELECTRICITY_TAX -> DatahubTariffFilterFactory.getReducedElectricityTax(); - case TRANSMISSION_NET_TARIFF -> DatahubTariffFilterFactory.getTransmissionNetTariff(); }; cacheManager.putTariffs(datahubTariff, downloadPriceLists(globalLocationNumber, filter)); } @@ -267,24 +268,24 @@ public class EnergiDataServiceHandler extends BaseThingHandler { return records; } - private DatahubTariffFilter getNetTariffFilter() { - Channel channel = getThing().getChannel(CHANNEL_NET_TARIFF); + private DatahubTariffFilter getGridTariffFilter() { + Channel channel = getThing().getChannel(CHANNEL_GRID_TARIFF); if (channel == null) { - return DatahubTariffFilterFactory.getNetTariffByGLN(config.gridCompanyGLN); + return DatahubTariffFilterFactory.getGridTariffByGLN(config.gridCompanyGLN); } DatahubPriceConfiguration datahubPriceConfiguration = channel.getConfiguration() .as(DatahubPriceConfiguration.class); if (!datahubPriceConfiguration.hasAnyFilterOverrides()) { - return DatahubTariffFilterFactory.getNetTariffByGLN(config.gridCompanyGLN); + return DatahubTariffFilterFactory.getGridTariffByGLN(config.gridCompanyGLN); } DateQueryParameter start = datahubPriceConfiguration.getStart(); if (start == null) { logger.warn("Invalid channel configuration parameter 'start' or 'offset': {} (offset: {})", datahubPriceConfiguration.start, datahubPriceConfiguration.offset); - return DatahubTariffFilterFactory.getNetTariffByGLN(config.gridCompanyGLN); + return DatahubTariffFilterFactory.getGridTariffByGLN(config.gridCompanyGLN); } Set chargeTypeCodes = datahubPriceConfiguration.getChargeTypeCodes(); @@ -295,7 +296,7 @@ public class EnergiDataServiceHandler extends BaseThingHandler { filter = new DatahubTariffFilter(chargeTypeCodes, notes, start); } else { // Only override start date in pre-configured filter. - filter = new DatahubTariffFilter(DatahubTariffFilterFactory.getNetTariffByGLN(config.gridCompanyGLN), + filter = new DatahubTariffFilter(DatahubTariffFilterFactory.getGridTariffByGLN(config.gridCompanyGLN), start); } @@ -341,13 +342,14 @@ public class EnergiDataServiceHandler extends BaseThingHandler { int i = 0; for (Entry sourcePrice : sourcePrices) { Instant hourStart = sourcePrice.getKey(); - BigDecimal netTariff = cacheManager.getTariff(DatahubTariff.NET_TARIFF, hourStart); + BigDecimal gridTariff = cacheManager.getTariff(DatahubTariff.GRID_TARIFF, hourStart); BigDecimal systemTariff = cacheManager.getTariff(DatahubTariff.SYSTEM_TARIFF, hourStart); + BigDecimal transmissionGridTariff = cacheManager.getTariff(DatahubTariff.TRANSMISSION_GRID_TARIFF, + hourStart); BigDecimal electricityTax = cacheManager.getTariff(DatahubTariff.ELECTRICITY_TAX, hourStart); BigDecimal reducedElectricityTax = cacheManager.getTariff(DatahubTariff.REDUCED_ELECTRICITY_TAX, hourStart); - BigDecimal transmissionNetTariff = cacheManager.getTariff(DatahubTariff.TRANSMISSION_NET_TARIFF, hourStart); - targetPrices[i++] = new Price(hourStart.toString(), sourcePrice.getValue(), config.currencyCode, netTariff, - systemTariff, electricityTax, reducedElectricityTax, transmissionNetTariff); + targetPrices[i++] = new Price(hourStart.toString(), sourcePrice.getValue(), config.currencyCode, gridTariff, + systemTariff, electricityTax, reducedElectricityTax, transmissionGridTariff); } updateState(CHANNEL_HOURLY_PRICES, new StringType(gson.toJson(targetPrices))); } diff --git a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties index b274c96e76d..ee8aa84ac78 100644 --- a/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties +++ b/bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties @@ -60,16 +60,16 @@ channel-group-type.energidataservice.electricity.label = Electricity channel-group-type.energidataservice.electricity.description = Channels related to electricity channel-group-type.energidataservice.electricity.channel.electricity-tax.label = Electricity Tax channel-group-type.energidataservice.electricity.channel.electricity-tax.description = Current electricity tax in DKK per kWh. -channel-group-type.energidataservice.electricity.channel.net-tariff.label = Net Tariff -channel-group-type.energidataservice.electricity.channel.net-tariff.description = Current net tariff in DKK per kWh. +channel-group-type.energidataservice.electricity.channel.grid-tariff.label = Grid Tariff +channel-group-type.energidataservice.electricity.channel.grid-tariff.description = Current grid tariff in DKK per kWh. channel-group-type.energidataservice.electricity.channel.reduced-electricity-tax.label = Reduced Electricity Tax channel-group-type.energidataservice.electricity.channel.reduced-electricity-tax.description = Current reduced electricity tax in DKK per kWh. For electric heating customers only. channel-group-type.energidataservice.electricity.channel.spot-price.label = Spot Price channel-group-type.energidataservice.electricity.channel.spot-price.description = Current spot price in DKK or EUR per kWh. channel-group-type.energidataservice.electricity.channel.system-tariff.label = System Tariff channel-group-type.energidataservice.electricity.channel.system-tariff.description = Current system tariff in DKK per kWh. -channel-group-type.energidataservice.electricity.channel.transmission-net-tariff.label = Transmission Net Tariff -channel-group-type.energidataservice.electricity.channel.transmission-net-tariff.description = Current transmission net tariff in DKK per kWh. +channel-group-type.energidataservice.electricity.channel.transmission-grid-tariff.label = Transmission Grid Tariff +channel-group-type.energidataservice.electricity.channel.transmission-grid-tariff.description = Current transmission grid tariff in DKK per kWh. # channel types 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 c978b03667b..83587c1e46a 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 @@ -12,14 +12,18 @@ Current spot price in DKK or EUR per kWh. - - - Current net tariff in DKK per kWh. + + + Current grid tariff in DKK per kWh. Current system tariff in DKK per kWh. + + + Current transmission grid tariff in DKK per kWh. + Current electricity tax in DKK per kWh. @@ -28,10 +32,6 @@ Current reduced electricity tax in DKK per kWh. For electric heating customers only. - - - Current transmission net tariff in DKK per kWh. - 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 b69ef51aa8e..805510a68ea 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 @@ - 1 + 2 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 62e288807ab..ef4dd6bd991 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 @@ -13,6 +13,21 @@ + + + energidataservice:datahub-price + + Current grid tariff in DKK per kWh. + + + energidataservice:datahub-price + + Current transmission grid tariff in DKK per kWh. + + + + + diff --git a/bundles/org.openhab.binding.energidataservice/src/test/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActionsTest.java b/bundles/org.openhab.binding.energidataservice/src/test/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActionsTest.java index c2dbfda85bb..d1ed9ae9d28 100644 --- a/bundles/org.openhab.binding.energidataservice/src/test/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActionsTest.java +++ b/bundles/org.openhab.binding.energidataservice/src/test/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActionsTest.java @@ -109,10 +109,10 @@ public class EnergiDataServiceActionsTest { } @Test - void getPricesNetTariff() throws IOException { + void getPricesGridTariff() throws IOException { mockCommonDatasets(actions); - Map actual = actions.getPrices("NetTariff"); + Map actual = actions.getPrices("GridTariff"); assertThat(actual.size(), is(60)); assertThat(actual.get(Instant.parse("2023-02-04T12:00:00Z")), is(equalTo(new BigDecimal("0.432225")))); assertThat(actual.get(Instant.parse("2023-02-04T16:00:00Z")), is(equalTo(new BigDecimal("1.05619")))); @@ -139,30 +139,30 @@ public class EnergiDataServiceActionsTest { } @Test - void getPricesTransmissionNetTariff() throws IOException { + void getPricesTransmissionGridTariff() throws IOException { mockCommonDatasets(actions); - Map actual = actions.getPrices("TransmissionNetTariff"); + Map actual = actions.getPrices("TransmissionGridTariff"); assertThat(actual.size(), is(60)); assertThat(actual.get(Instant.parse("2023-02-04T12:00:00Z")), is(equalTo(new BigDecimal("0.058")))); assertThat(actual.get(Instant.parse("2023-02-04T16:00:00Z")), is(equalTo(new BigDecimal("0.058")))); } @Test - void getPricesSpotPriceNetTariff() throws IOException { + void getPricesSpotPriceGridTariff() throws IOException { mockCommonDatasets(actions); - Map actual = actions.getPrices("SpotPrice,NetTariff"); + Map actual = actions.getPrices("SpotPrice,GridTariff"); assertThat(actual.size(), is(35)); assertThat(actual.get(Instant.parse("2023-02-04T12:00:00Z")), is(equalTo(new BigDecimal("1.425065027")))); assertThat(actual.get(Instant.parse("2023-02-04T16:00:00Z")), is(equalTo(new BigDecimal("2.323870054")))); } @Test - void getPricesSpotPriceNetTariffElectricityTax() throws IOException { + void getPricesSpotPriceGridTariffElectricityTax() throws IOException { mockCommonDatasets(actions); - Map actual = actions.getPrices("SpotPrice,NetTariff,ElectricityTax"); + Map actual = actions.getPrices("SpotPrice,GridTariff,ElectricityTax"); assertThat(actual.size(), is(35)); assertThat(actual.get(Instant.parse("2023-02-04T12:00:00Z")), is(equalTo(new BigDecimal("1.433065027")))); assertThat(actual.get(Instant.parse("2023-02-04T16:00:00Z")), is(equalTo(new BigDecimal("2.331870054")))); @@ -202,7 +202,7 @@ public class EnergiDataServiceActionsTest { mockCommonDatasets(actions); Map actual = actions - .getPrices("spotprice,nettariff,systemtariff,electricitytax,transmissionnettariff"); + .getPrices("spotprice,gridtariff,systemtariff,electricitytax,transmissiongridtariff"); assertThat(actual.size(), is(35)); assertThat(actual.get(Instant.parse("2023-02-04T12:00:00Z")), is(equalTo(new BigDecimal("1.545065027")))); assertThat(actual.get(Instant.parse("2023-02-04T15:00:00Z")), is(equalTo(new BigDecimal("1.708765039")))); @@ -213,7 +213,7 @@ public class EnergiDataServiceActionsTest { void getPricesInvalidPriceComponent() throws IOException { mockCommonDatasets(actions); - Map actual = actions.getPrices("spotprice,nettarif"); + Map actual = actions.getPrices("spotprice,gridtarif"); assertThat(actual.size(), is(0)); } @@ -222,7 +222,7 @@ public class EnergiDataServiceActionsTest { mockCommonDatasets(actions); when(handler.getCurrency()).thenReturn(EnergiDataServiceBindingConstants.CURRENCY_EUR); - Map actual = actions.getPrices("spotprice,nettariff"); + Map actual = actions.getPrices("spotprice,gridtariff"); assertThat(actual.size(), is(0)); } @@ -404,8 +404,8 @@ public class EnergiDataServiceActionsTest { PriceListParser priceListParser = new PriceListParser( Clock.fixed(spotPriceRecords[0].hourStart, EnergiDataServiceBindingConstants.DATAHUB_TIMEZONE)); - DatahubPricelistRecords datahubRecords = getObjectFromJson("NetTariffs.json", DatahubPricelistRecords.class); - Map netTariffs = priceListParser + DatahubPricelistRecords datahubRecords = getObjectFromJson("GridTariffs.json", DatahubPricelistRecords.class); + Map gridTariffs = priceListParser .toHourly(Arrays.stream(datahubRecords.records()).toList()); datahubRecords = getObjectFromJson("SystemTariffs.json", DatahubPricelistRecords.class); Map systemTariffs = priceListParser @@ -416,16 +416,16 @@ public class EnergiDataServiceActionsTest { datahubRecords = getObjectFromJson("ReducedElectricityTaxes.json", DatahubPricelistRecords.class); Map reducedElectricityTaxes = priceListParser .toHourly(Arrays.stream(datahubRecords.records()).toList()); - datahubRecords = getObjectFromJson("TransmissionNetTariffs.json", DatahubPricelistRecords.class); - Map transmissionNetTariffs = priceListParser + datahubRecords = getObjectFromJson("TransmissionGridTariffs.json", DatahubPricelistRecords.class); + Map transmissionGridTariffs = priceListParser .toHourly(Arrays.stream(datahubRecords.records()).toList()); when(handler.getSpotPrices()).thenReturn(spotPrices); - when(handler.getTariffs(DatahubTariff.NET_TARIFF)).thenReturn(netTariffs); + when(handler.getTariffs(DatahubTariff.GRID_TARIFF)).thenReturn(gridTariffs); when(handler.getTariffs(DatahubTariff.SYSTEM_TARIFF)).thenReturn(systemTariffs); + when(handler.getTariffs(DatahubTariff.TRANSMISSION_GRID_TARIFF)).thenReturn(transmissionGridTariffs); when(handler.getTariffs(DatahubTariff.ELECTRICITY_TAX)).thenReturn(electricityTaxes); when(handler.getTariffs(DatahubTariff.REDUCED_ELECTRICITY_TAX)).thenReturn(reducedElectricityTaxes); - when(handler.getTariffs(DatahubTariff.TRANSMISSION_NET_TARIFF)).thenReturn(transmissionNetTariffs); when(handler.getCurrency()).thenReturn(EnergiDataServiceBindingConstants.CURRENCY_DKK); when(handler.isReducedElectricityTax()).thenReturn(isReducedElectricityTax); actions.setThingHandler(handler); diff --git a/bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/NetTariffs.json b/bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/GridTariffs.json similarity index 100% rename from bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/NetTariffs.json rename to bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/GridTariffs.json diff --git a/bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/TransmissionNetTariffs.json b/bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/TransmissionGridTariffs.json similarity index 100% rename from bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/TransmissionNetTariffs.json rename to bundles/org.openhab.binding.energidataservice/src/test/resources/org/openhab/binding/energidataservice/internal/action/TransmissionGridTariffs.json