Bringing electricity information from eloverblik.dk and energidataservice.dk into Openhab

Hi @laursen
Hope you’re doing well! I’ve run OH 4.0.x for some days and noticed a very tiny issue with EnergiDataService binding, maybe because I don’t fully understand how it works.
I have a simple rule like below:

when     
    Item TotalPrice changed 
then
    var Number currPrice = TotalPrice.state as Number
    logInfo("EnergiDataService", "Current electricity price is {}kr/kWh", String.format("%.2f", currPrice.doubleValue))
    }
end

Item definition:

Group:Number:SUM    TotalPrice                    "Current El Total Price [%.2f kr]"            <price>    (gEnergiDataService)
Number              SpotPrice                     "Current El Spot Price [%.2f kr]"             <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#spot-price" [profile="transform:VAT"]}
Number              NetTariff                     "Current El Net Tariff [%.2f kr]"             <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#net-tariff" [profile="transform:VAT"]}
Number              SystemTariff                  "Current El System Tariff [%.2f kr]"          <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#system-tariff" [profile="transform:VAT"]}
Number              ElectricityTax                "Current El Electricity Tax [%.2f kr]"        <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#electricity-tax" [profile="transform:VAT"]}
Number              TransmissionNetTariff         "Current El Transmission Tariff [%.2f kr]"    <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#transmission-net-tariff" [profile="transform:VAT"]}
String 

In the log it looks like for some hours the TotalPrice changes twice, and it happens everyday at 21:00, and also sometimes 17:00, 13:00 and 8:00. The strange thing is only at 21:00 it always get 2 different prices:

**2023-08-26 00:00:00.008 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.22kr/kWh**
**2023-08-26 00:00:00.011 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.22kr/kWh**
2023-08-26 01:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.17kr/kWh
2023-08-26 02:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.15kr/kWh
2023-08-26 03:00:00.007 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.13kr/kWh
2023-08-26 04:00:00.018 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.10kr/kWh
2023-08-26 05:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.07kr/kWh
2023-08-26 06:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.18kr/kWh
2023-08-26 07:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.19kr/kWh
**2023-08-26 08:00:00.007 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.21kr/kWh**
**2023-08-26 08:00:00.008 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.21kr/kWh**
2023-08-26 09:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.16kr/kWh
2023-08-26 10:00:00.022 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.09kr/kWh
2023-08-26 11:00:00.074 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.04kr/kWh
2023-08-26 12:00:00.004 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.92kr/kWh
**2023-08-26 13:00:00.019 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.73kr/kWh**
**2023-08-26 13:00:29.392 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.73kr/kWh**
2023-08-26 14:00:00.012 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.67kr/kWh
2023-08-26 15:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.00kr/kWh
2023-08-26 16:00:00.008 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.10kr/kWh
2023-08-26 17:00:00.629 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.63kr/kWh
2023-08-26 18:00:00.004 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.71kr/kWh
2023-08-26 19:00:00.025 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.90kr/kWh
2023-08-26 20:00:00.039 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.98kr/kWh
**2023-08-26 21:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 3.01kr/kWh**
**2023-08-26 21:00:00.012 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.55kr/kWh**

I have experienced this for a few days in a row, and I think it has something to do with the event:

Item 'NetTariff' changed from 0.73587500 to 0.28300000

So my guess what happened:

  1. At 21:00 it first calculate price based on NetTariff at 20:00
  2. Then the NetTariff has changed to 0,283
  3. It re-calculate total price based on new NetTariff

Hope you can take a look :slight_smile:

You don’t need to log this from a rule, you can simply inspect events.log. I can also see this from time to time, last it happened here:

2023-08-26 17:00:00.057 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_SpotPrice' changed from 0.80941253625 to 0.88488746625
2023-08-26 17:00:00.072 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'EnergiDataService_TotalPrice' changed from 1.82691253625 to 1.90238746625 through EnergiDataService_NetTariff
2023-08-26 17:00:00.075 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'EnergiDataService_TotalPrice' changed from 1.82691253625 to 1.90238746625 through EnergiDataService_SpotPrice

I’m not sure why the group item was updated though EnergiDataService_NetTariff when EnergiDataService_NetTariff didn’t change. The channel receives an update, but the value is unchanged in this case. I would expect it to happen consistently, i.e. never or always. It might be timing-related.

In any case, this problem is to be found/fixed outside of the binding.

1 Like

Thank you for looking into it!
I now change the rule to check price 1 second after each hour and will report if the workaround is a good one :slight_smile: Have a great evening!

The mentioned pull request is now merged, and I have implemented support for persisted future prices in the Energi Data Service binding. So here’s a small teaser:

Additionally, I have updated the VAT profile to support time series as well:

1 Like

Great thanks! I will wait for the update and if possible can you write some quick instructions on how to use/show the timeseries?

It will be in the documentation. The current PR version is here:

In short, you shouldn’t have to do anything. However, changing persistence strategy to forecast will ensure a cleaner history as only time series will be persisted, not any hourly updates.

The PR was merged yesterday, so you can now find it here:

1 Like

Thank you! Will find some time to give a try and let you know how it goes, appreciated!

Please note that the core feature that it depends upon was merged after 4.1 milestone 3, so it is currently only available in the 4.1 snapshots.

1 Like

I will wait for 4.1.0 release then, thanks

Hi, I have just tried installing OpenHAB 4.1.0.M4 and have attempted to use the new feature "Persisting Time Series. However, I cannot see any data on the graph in the UI, only the prices for the time that I have had the version running. The following message appears in the log:

Blockquote

Item ‘Energi_Data_Service_Spotpris’ shall process timeseries [Entry[timestamp=2023-12-07T14:00:00Z, state=1.2862374875], Entry[timestamp=2023-12-07T15:00:00Z, state=1.24756248500], Entry[timestamp=2023-12-07T16:00:00Z, state=1.19834999125], Entry[timestamp=2023-12-07T17:00:00Z, state=1.12156250], Entry[timestamp=2023-12-07T18:00:00Z, state=0.97050003000], Entry[timestamp=2023-12-07T19:00:00Z, state=0.93527496375], Entry[timestamp=2023-12-07T20:00:00Z, state=0.90396247875], Entry[timestamp=2023-12-07T21:00:00Z, state=0.89855003375], Entry[timestamp=2023-12-07T22:00:00Z, state=0.81151252750], Entry[timestamp=2023-12-07T23:00:00Z, state=0.8115499875], Entry[timestamp=2023-12-08T00:00:00Z, state=0.77586250250], Entry[timestamp=2023-12-08T01:00:00Z, state=0.75881248500], Entry[timestamp=2023-12-08T02:00:00Z, state=0.74101249750], Entry[timestamp=2023-12-08T03:00:00Z, state=0.74548751875], Entry[timestamp=2023-12-08T04:00:00Z, state=0.81108749375], Entry[timestamp=2023-12-08T05:00:00Z, state=0.92896247875], Entry[timestamp=2023-12-08T06:00:00Z, state=0.99978752125], Entry[timestamp=2023-12-08T07:00:00Z, state=1.04973747250], Entry[timestamp=2023-12-08T08:00:00Z, state=1.10443748500], Entry[timestamp=2023-12-08T09:00:00Z, state=1.1065750125], Entry[timestamp=2023-12-08T10:00:00Z, state=1.09977500875], Entry[timestamp=2023-12-08T11:00:00Z, state=1.08709999125], Entry[timestamp=2023-12-08T12:00:00Z, state=1.04162498500], Entry[timestamp=2023-12-08T13:00:00Z, state=1.05178749125], Entry[timestamp=2023-12-08T14:00:00Z, state=1.07862503000], Entry[timestamp=2023-12-08T15:00:00Z, state=1.05625000], Entry[timestamp=2023-12-08T16:00:00Z, state=1.09613746625], Entry[timestamp=2023-12-08T17:00:00Z, state=1.10517501875], Entry[timestamp=2023-12-08T18:00:00Z, state=0.9821749875], Entry[timestamp=2023-12-08T19:00:00Z, state=0.97238746625], Entry[timestamp=2023-12-08T20:00:00Z, state=0.94228752125], Entry[timestamp=2023-12-08T21:00:00Z, state=0.94480003375], Entry[timestamp=2023-12-08T22:00:00Z, state=0.8440750125], Entry[timestamp=2023-12-08T23:00:00Z, state=0.8852999875], Entry[timestamp=2023-12-09T00:00:00Z, state=0.79305000250], Entry[timestamp=2023-12-09T01:00:00Z, state=0.74076248125], Entry[timestamp=2023-12-09T02:00:00Z, state=0.68093750], Entry[timestamp=2023-12-09T03:00:00Z, state=0.65754997250], Entry[timestamp=2023-12-09T04:00:00Z, state=0.68037498500], Entry[timestamp=2023-12-09T05:00:00Z, state=0.70861251875], Entry[timestamp=2023-12-09T06:00:00Z, state=0.76788749750], Entry[timestamp=2023-12-09T07:00:00Z, state=0.79146247875], Entry[timestamp=2023-12-09T08:00:00Z, state=0.85250000], Entry[timestamp=2023-12-09T09:00:00Z, state=0.84411247250], Entry[timestamp=2023-12-09T10:00:00Z, state=0.8446749875], Entry[timestamp=2023-12-09T11:00:00Z, state=0.8506375125], Entry[timestamp=2023-12-09T12:00:00Z, state=0.82650001500], Entry[timestamp=2023-12-09T13:00:00Z, state=0.79798751875], Entry[timestamp=2023-12-09T14:00:00Z, state=0.7781375125], Entry[timestamp=2023-12-09T15:00:00Z, state=0.7462625125], Entry[timestamp=2023-12-09T16:00:00Z, state=0.7365750125], Entry[timestamp=2023-12-09T17:00:00Z, state=0.7215750125], Entry[timestamp=2023-12-09T18:00:00Z, state=0.6472000125], Entry[timestamp=2023-12-09T19:00:00Z, state=0.60069999750], Entry[timestamp=2023-12-09T20:00:00Z, state=0.56296249375], Entry[timestamp=2023-12-09T21:00:00Z, state=0.52968750], Entry[timestamp=2023-12-09T22:00:00Z, state=0.43034999875]]

In the configuration for RRD4J Persistence, I have added a configuration where I have chosen the item ‘spotpris’ to be persisted with the ‘forecast’ strategy.

Have I misunderstood something? I understood that the historical and future data should be persisted along with the current prices, so you could see them on the same graph, is that correct?

No, you have not misunderstood. Can you share your persistence configuration and graph details?

sure :slightly_smiling_face: It is a clean installation, and the only addons are Energy Data Service and RRDJ4 Persistence

Persistence:

configurations:
  - items:
      - Energi_Data_Service_Spotpris
    strategies:
      - forecast
    filters: []
cronStrategies:
  - name: everyMinute
    cronExpression: 0 * * ? * *
  - name: everyHour
    cronExpression: 0 0 * * * ?
  - name: everyDay
    cronExpression: 0 0 0 * * ?
defaultStrategies:
  - everyChange
thresholdFilters: []
timeFilters: []
equalsFilters: []
includeFilters: []

Chart:

config:
  chartType: ""
  period: D
  label: Spotpris
slots:
  grid:
    - component: oh-chart-grid
      config:
        includeLabels: true
  xAxis:
    - component: oh-time-axis
      config:
        gridIndex: 0
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
  series:
    - component: oh-time-series
      config:
        name: Spotpris
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: line
        item: Energi_Data_Service_Spotpris
  tooltip:
    - component: oh-chart-tooltip
      config:
        confine: true
        smartFormatter: true
  legend:
    - component: oh-chart-legend
      config:
        bottom: 3
        type: scroll
  dataZoom:
    - component: oh-chart-datazoom
      config:
        type: inside

Just to be sure, was the item already configured to be persisted before starting the binding? Does the issue persist if you pause/resume the Thing?

I first entered the Energy Data Service and added an item for spot price. After that, I went to RRDJ4 to configure this item to follow the forecast strategy.

It doesn’t change if I pause/resume the thing, a restart doesn’t help either.

It looks like RRD4j implements only QueryablePersistenceService:

and not ModifiablePersistenceService which is needed for storing time series.

Therefore you’ll need to use another persistence service to take advantage of this feature.

Hi Jacob,
Finally got some time to upgrade to 4.1.0 and would like to test the time series.
Which persistency service do you use? I’m currently also using RRD4J but are thinking to move to InfluxDB. Have you got any experience with it?

Also another question regarding “reduced electricity tax rate”, how does it affect hourly price and calculations? Or does it simply use the reduced electricity tax rate for hourly price and calculations without considering the 4000kWh threshold?

Edit: BTW I noticed today the El Net Tariff was changed from 0,456kr to 1.367kr at 18:00 instead of 17:00, maybe an issue with the data provider :smiley:

I would recommend upgrading to 4.1.1 since it contains some fixes for Energi Data Service as well as in-memory persistence and core fixes related to the new currency unit.

No, but it implements ModifiablePersistenceService, so it should work just fine. Personally I use MySQL for historical reasons (I’ve been running it for 20 years or so), as I already had an instance running when I got started with openHAB.

See Energi Data Service - Bindings | openHAB. The 4000 kWh threshold is not considered as there wouldn’t be any logical reason to do so. See Energi Data Service Binding [4.0.0.0;4.1.0.0) - #41 by laursen.

1 Like

Thanks for your reply! I noticed today the El Net Tariff was changed from 0,456kr to 1.367kr at 18:00 instead of 17:00, do you see the same issue with your installation? Would like to exclude something wrong with my setup. In previous days it did change at 17:00.

What is the exact name of your grid provider (or its GLN)?