Skip to content

Commit

Permalink
Rename channels net-tariff and transmission-net-tariff (openhab#15938)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <[email protected]>
Signed-off-by: Jørgen Austvik <[email protected]>
  • Loading branch information
jlaur authored and austvik committed Mar 27, 2024
1 parent ab49fa2 commit 332902e
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 97 deletions.
68 changes: 34 additions & 34 deletions bundles/org.openhab.binding.energidataservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 |
|-----------------|---------|----------------------------------------------------------------------------------------------------------------------------------|---------|----------|----------|
Expand Down Expand Up @@ -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
}
]
```
Expand Down Expand Up @@ -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`.
Expand All @@ -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
Expand All @@ -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" ]
}
```

Expand All @@ -369,10 +369,10 @@ Thing energidataservice:service:energidataservice "Energi Data Service" [ priceA
```java
Group:Number:SUM TotalPrice "Current Total Price" <price>
Number SpotPrice "Current Spot Price" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#spot-price" [profile="transform:VAT"] }
Number NetTariff "Current Net Tariff" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#net-tariff" [profile="transform:VAT"] }
Number GridTariff "Current Grid Tariff" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#grid-tariff" [profile="transform:VAT"] }
Number SystemTariff "Current System Tariff" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#system-tariff" [profile="transform:VAT"] }
Number TransmissionGridTariff "Current Transmission Grid Tariff" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#transmission-grid-tariff" [profile="transform:VAT"] }
Number ElectricityTax "Current Electricity Tax" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#electricity-tax" [profile="transform:VAT"] }
Number TransmissionNetTariff "Current Transmission Tariff" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#transmission-net-tariff" [profile="transform:VAT"] }
String HourlyPrices "Hourly Prices" <price> { channel="energidataservice:service:energidataservice:electricity#hourly-prices" }
```

Expand All @@ -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)
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
*/
@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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, PriceComponent> NAME_MAP = Stream.of(values())
.collect(Collectors.toMap(PriceComponent::toString, Function.identity()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down Expand Up @@ -167,6 +167,11 @@ public static DatahubTariffFilter getSystemTariff() {
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));
Expand All @@ -176,9 +181,4 @@ public static DatahubTariffFilter getReducedElectricityTax() {
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));
}
}
Loading

0 comments on commit 332902e

Please sign in to comment.