Skip to content

Commit

Permalink
Remove current prefixes for forward compatibility with timestamped items
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <[email protected]>
  • Loading branch information
jlaur committed May 19, 2023
1 parent 9c3ce2a commit 3506e60
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 69 deletions.
36 changes: 18 additions & 18 deletions bundles/org.openhab.binding.energidataservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ To obtain the Global Location Number of your grid company:

### Channel Group `electricity`

| Channel | Type | Description | Advanced |
|---------------------------------|--------|------------------------------------------------------------------------------------------------|----------|
| current-spot-price | Number | Spot price in DKK or EUR per kWh for current hour | no |
| current-net-tariff | Number | Net tariff in DKK per kWh for current hour. Only available when `gridCompanyGLN` is configured | no |
| current-system-tariff | Number | System tariff in DKK per kWh for current hour | no |
| current-electricity-tax | Number | Electricity tax in DKK per kWh for current hour | no |
| current-transmission-net-tariff | Number | Transmission net tariff in DKK per kWh for current hour | no |
| hourly-prices | String | JSON array with hourly prices from 12 hours ago and onward | yes |
| 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 |
| transmission-net-tariff | Number | Current transmission net tariff in DKK per kWh | no |
| hourly-prices | String | JSON array with hourly prices from 12 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 @@ -63,13 +63,13 @@ To include VAT for items linked to the `Number` channels, the [VAT profile](http
This must be installed separately.
Once installed, simply select "Value-Added Tax" as Profile when linking an item.

#### Current Net Tariff
#### Net Tariff

Discounts are automatically taken into account for channel `current-net-tariff` so that it represents the actual price.
Discounts are automatically taken into account for channel `net-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 `current-net-tariff` has the following configuration parameters:
To override filters, the channel `net-tariff` has the following configuration parameters:

| Name | Type | Description | Default | Required | Advanced |
|-----------------|---------|----------------------------------------------------------------------------------------------------------------------------|---------|----------|----------|
Expand Down Expand Up @@ -320,19 +320,19 @@ var priceMap = actions.getPrices("SpotPrice,NetTariff");
```java
Thing energidataservice:service:energidataservice "Energi Data Service" [ priceArea="DK1", currencyCode="DKK", gridCompanyGLN="5790001089030" ] {
Channels:
Number : electricity#current-net-tariff [ chargeTypeCodes="CD,CD R", start="StartOfYear" ]
Number : electricity#net-tariff [ chargeTypeCodes="CD,CD R", start="StartOfYear" ]
}
```

### Item Configuration

```java
Group:Number:SUM CurrentTotalPrice "Current Total Price" <price>
Number CurrentSpotPrice "Current Spot Price" <price> (CurrentTotalPrice) { channel="energidataservice:service:energidataservice:electricity#current-spot-price" [profile="transform:VAT"] }
Number CurrentNetTariff "Current Net Tariff" <price> (CurrentTotalPrice) { channel="energidataservice:service:energidataservice:electricity#current-net-tariff" [profile="transform:VAT"] }
Number CurrentSystemTariff "Current System Tariff" <price> (CurrentTotalPrice) { channel="energidataservice:service:energidataservice:electricity#current-system-tariff" [profile="transform:VAT"] }
Number CurrentElectricityTax "Current Electricity Tax" <price> (CurrentTotalPrice) { channel="energidataservice:service:energidataservice:electricity#current-electricity-tax" [profile="transform:VAT"] }
Number CurrentTransmissionNetTariff "Current Transmission Tariff" <price> (CurrentTotalPrice) { channel="energidataservice:service:energidataservice:electricity#current-transmission-net-tariff" [profile="transform:VAT"] }
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 SystemTariff "Current System Tariff" <price> (TotalPrice) { channel="energidataservice:service:energidataservice:electricity#system-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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,21 @@ public class EnergiDataServiceBindingConstants {
public static final String CHANNEL_GROUP_ELECTRICITY = "electricity";

// List of all Channel ids
public static final String CHANNEL_CURRENT_SPOT_PRICE = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "current-spot-price";
public static final String CHANNEL_CURRENT_NET_TARIFF = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "current-net-tariff";
public static final String CHANNEL_CURRENT_SYSTEM_TARIFF = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "current-system-tariff";
public static final String CHANNEL_CURRENT_ELECTRICITY_TAX = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "current-electricity-tax";
public static final String CHANNEL_CURRENT_TRANSMISSION_NET_TARIFF = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "current-transmission-net-tariff";
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_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_TRANSMISSION_NET_TARIFF = CHANNEL_GROUP_ELECTRICITY
+ ChannelUID.CHANNEL_GROUP_SEPARATOR + "transmission-net-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_CURRENT_SPOT_PRICE,
CHANNEL_CURRENT_NET_TARIFF, CHANNEL_CURRENT_SYSTEM_TARIFF, CHANNEL_CURRENT_ELECTRICITY_TAX,
CHANNEL_CURRENT_TRANSMISSION_NET_TARIFF, CHANNEL_HOURLY_PRICES);
public static final Set<String> ELECTRICITY_CHANNELS = Set.of(CHANNEL_SPOT_PRICE, CHANNEL_NET_TARIFF,
CHANNEL_SYSTEM_TARIFF, CHANNEL_ELECTRICITY_TAX, CHANNEL_TRANSMISSION_NET_TARIFF, 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 @@ -166,30 +166,30 @@ public Collection<Class<? extends ThingHandlerService>> getServices() {
private void refreshElectricityPrices() {
RetryStrategy retryPolicy;
try {
if (isLinked(CHANNEL_CURRENT_SPOT_PRICE) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (isLinked(CHANNEL_SPOT_PRICE) || isLinked(CHANNEL_HOURLY_PRICES)) {
downloadSpotPrices();
}

if (isLinked(CHANNEL_CURRENT_NET_TARIFF) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (isLinked(CHANNEL_NET_TARIFF) || isLinked(CHANNEL_HOURLY_PRICES)) {
downloadNetTariffs();
}

if (isLinked(CHANNEL_CURRENT_SYSTEM_TARIFF) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (isLinked(CHANNEL_SYSTEM_TARIFF) || isLinked(CHANNEL_HOURLY_PRICES)) {
downloadSystemTariffs();
}

if (isLinked(CHANNEL_CURRENT_ELECTRICITY_TAX) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (isLinked(CHANNEL_ELECTRICITY_TAX) || isLinked(CHANNEL_HOURLY_PRICES)) {
downloadElectricityTaxes();
}

if (isLinked(CHANNEL_CURRENT_TRANSMISSION_NET_TARIFF) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (isLinked(CHANNEL_TRANSMISSION_NET_TARIFF) || isLinked(CHANNEL_HOURLY_PRICES)) {
downloadTransmissionNetTariffs();
}

updateStatus(ThingStatus.ONLINE);
updatePrices();

if (isLinked(CHANNEL_CURRENT_SPOT_PRICE) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (isLinked(CHANNEL_SPOT_PRICE) || isLinked(CHANNEL_HOURLY_PRICES)) {
if (cacheManager.getNumberOfFutureSpotPrices() < 13) {
retryPolicy = RetryPolicyFactory.whenExpectedSpotPriceDataMissing(DAILY_REFRESH_TIME_CET,
NORD_POOL_TIMEZONE);
Expand Down Expand Up @@ -303,7 +303,7 @@ private Collection<DatahubPricelistRecord> downloadPriceLists(GlobalLocationNumb
}

private DatahubTariffFilter getNetTariffFilter() {
Channel channel = getThing().getChannel(CHANNEL_CURRENT_NET_TARIFF);
Channel channel = getThing().getChannel(CHANNEL_NET_TARIFF);
if (channel == null) {
return DatahubTariffFilterFactory.getNetTariffByGLN(config.gridCompanyGLN);
}
Expand Down Expand Up @@ -336,21 +336,21 @@ private void updatePrices() {
cacheManager.cleanup();

updateCurrentSpotPrice();
updateCurrentTariff(CHANNEL_CURRENT_NET_TARIFF, cacheManager.getNetTariff());
updateCurrentTariff(CHANNEL_CURRENT_SYSTEM_TARIFF, cacheManager.getSystemTariff());
updateCurrentTariff(CHANNEL_CURRENT_ELECTRICITY_TAX, cacheManager.getElectricityTax());
updateCurrentTariff(CHANNEL_CURRENT_TRANSMISSION_NET_TARIFF, cacheManager.getTransmissionNetTariff());
updateCurrentTariff(CHANNEL_NET_TARIFF, cacheManager.getNetTariff());
updateCurrentTariff(CHANNEL_SYSTEM_TARIFF, cacheManager.getSystemTariff());
updateCurrentTariff(CHANNEL_ELECTRICITY_TAX, cacheManager.getElectricityTax());
updateCurrentTariff(CHANNEL_TRANSMISSION_NET_TARIFF, cacheManager.getTransmissionNetTariff());
updateHourlyPrices();

reschedulePriceUpdateJob();
}

private void updateCurrentSpotPrice() {
if (!isLinked(CHANNEL_CURRENT_SPOT_PRICE)) {
if (!isLinked(CHANNEL_SPOT_PRICE)) {
return;
}
BigDecimal spotPrice = cacheManager.getSpotPrice();
updateState(CHANNEL_CURRENT_SPOT_PRICE, spotPrice != null ? new DecimalType(spotPrice) : UnDefType.UNDEF);
updateState(CHANNEL_SPOT_PRICE, spotPrice != null ? new DecimalType(spotPrice) : UnDefType.UNDEF);
}

private void updateCurrentTariff(String channelId, @Nullable BigDecimal tariff) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ thing-type.config.energidataservice.service.priceArea.option.DK2 = East of the G

channel-group-type.energidataservice.electricity.label = Electricity
channel-group-type.energidataservice.electricity.description = Channels related to electricity
channel-group-type.energidataservice.electricity.channel.current-electricity-tax.label = Current Electricity Tax
channel-group-type.energidataservice.electricity.channel.current-electricity-tax.description = Electricity Tax in DKK per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-net-tariff.label = Current Net Tariff
channel-group-type.energidataservice.electricity.channel.current-net-tariff.description = Net tariff in DKK per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-spot-price.label = Current Spot Price
channel-group-type.energidataservice.electricity.channel.current-spot-price.description = Spot price in DKK or EUR per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-system-tariff.label = Current System Tariff
channel-group-type.energidataservice.electricity.channel.current-system-tariff.description = System tariff in DKK per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-transmission-net-tariff.label = Current Transmission Tariff
channel-group-type.energidataservice.electricity.channel.current-transmission-net-tariff.description = Transmission Net Tariff in DKK per kWh for current hour.
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.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 types

Expand All @@ -86,6 +86,19 @@ channel-type.config.energidataservice.datahub-price.start.option.StartOfDay = St
channel-type.config.energidataservice.datahub-price.start.option.StartOfMonth = Start of month
channel-type.config.energidataservice.datahub-price.start.option.StartOfYear = Start of year

# channel group types

channel-group-type.energidataservice.electricity.channel.current-electricity-tax.label = Current Electricity Tax
channel-group-type.energidataservice.electricity.channel.current-electricity-tax.description = Electricity Tax in DKK per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-net-tariff.label = Current Net Tariff
channel-group-type.energidataservice.electricity.channel.current-net-tariff.description = Net tariff in DKK per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-spot-price.label = Current Spot Price
channel-group-type.energidataservice.electricity.channel.current-spot-price.description = Spot price in DKK or EUR per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-system-tariff.label = Current System Tariff
channel-group-type.energidataservice.electricity.channel.current-system-tariff.description = System tariff in DKK per kWh for current hour.
channel-group-type.energidataservice.electricity.channel.current-transmission-net-tariff.label = Current Transmission Tariff
channel-group-type.energidataservice.electricity.channel.current-transmission-net-tariff.description = Transmission Net Tariff in DKK per kWh for current hour.

# thing status descriptions

offline.conf-error.no-price-area = Price area must be set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
<label>Electricity</label>
<description>Channels related to electricity</description>
<channels>
<channel id="current-spot-price" typeId="spot-price">
<label>Current Spot Price</label>
<description>Spot price in DKK or EUR per kWh for current hour.</description>
<channel id="spot-price" typeId="spot-price">
<label>Spot Price</label>
<description>Current spot price in DKK or EUR per kWh.</description>
</channel>
<channel id="current-net-tariff" typeId="datahub-price">
<label>Current Net Tariff</label>
<description>Net tariff in DKK per kWh for current hour.</description>
<channel id="net-tariff" typeId="datahub-price">
<label>Net Tariff</label>
<description>Current net tariff in DKK per kWh.</description>
</channel>
<channel id="current-system-tariff" typeId="datahub-price">
<label>Current System Tariff</label>
<description>System tariff in DKK per kWh for current hour.</description>
<channel id="system-tariff" typeId="datahub-price">
<label>System Tariff</label>
<description>Current system tariff in DKK per kWh.</description>
</channel>
<channel id="current-electricity-tax" typeId="datahub-price">
<label>Current Electricity Tax</label>
<description>Electricity Tax in DKK per kWh for current hour.</description>
<channel id="electricity-tax" typeId="datahub-price">
<label>Electricity Tax</label>
<description>Current electricity tax in DKK per kWh.</description>
</channel>
<channel id="current-transmission-net-tariff" typeId="datahub-price">
<label>Current Transmission Tariff</label>
<description>Transmission Net Tariff in DKK per kWh for current hour.</description>
<channel id="transmission-net-tariff" typeId="datahub-price">
<label>Transmission Net Tariff</label>
<description>Current transmission net tariff in DKK per kWh.</description>
</channel>
<channel id="hourly-prices" typeId="hourly-prices"/>
</channels>
Expand Down

0 comments on commit 3506e60

Please sign in to comment.