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

There could be some issue when the date rolls - I need to find a smart way to remove prices from all items tomorrow I guess. The best way to do it is to remove all prices first and add them back based on the new date/getPrices, however it will give issue if there are only 12 hours history. Also if HourlyPrice is only updated once at 13:00 per day, I might miss an hour price at 00:00 (midnight). It would be nice to include all hours for “today” I think - it’s better than going back 12/24 hours as in that case the date can be yesterday.

Yes the VAT transformer is installed and working correctly for other items like spot price. I cannot use ItemChannelLink as my items don’t have channels, so I took the display example, maybe it’s only for display in UI (sorry I never use the UI part of OpenHAB)?

Thank you!

Yes, at least you could verify if it’s working by checking the UI. To apply VAT to your 48 channels, you might want to do that directly in your rule by:

transform("VAT", "DK", price.toString)

You could have a rule triggered at midnight (by cron event) which will copy “tomorrow” items into “today” items and set “tomorrow” items to UNDEF, i.e. to do the roll. Another trigger could be when an item linked to channel hourly-prices changed, i.e. when the prices are updated around 13:00. This could then update “tomorrow” items as this is the moment when they become available. This would also ensure it would work if the spot prices are not available at 13:00 for any reason - as soon as they will be, you will have your items updated.

I will update the binding to keep 12 hours of history or all hours today - whichever will be the most.

1 Like

I checked the event log, and it looks like HourlyPrice is updated once per hour at XX:00:00. I have modified my rule to the following which also reset tmr prices if none is in the price feed:

rule "Update electricity price list"
when     
    Item HourlyPrices changed
    or Time cron "0 * * * * ? *"
then
    val actions = getActions("energidataservice", "energidataservice:service:energidataservice")
    var priceMap = actions.getPrices(null)
    var DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
    var LocalDateTime today = LocalDateTime.now()
    var LocalDateTime tomorrow = today.plusDays(1)
    var Boolean isTmrPriceAvailable = false
    var Boolean isTmrPriceDefined = gEnergiDataServiceTomorrow.members.filter[ item | item.state == UNDEF ].size == 0
    priceMap.forEach[ key, value | 
        var LocalDateTime ldt = LocalDateTime.ofInstant(key, ZoneOffset.systemDefault())
        var DateTimeFormatter hourFormatter = DateTimeFormatter.ofPattern("HH");
        var String dateStr = ldt.format(dateFormatter)
        var String hourStr = ldt.format(hourFormatter)
        var String itemName = "PriceAt" + hourStr
        if(dateStr == tomorrow.format(dateFormatter)) {
            isTmrPriceAvailable = true
  			gEnergiDataServiceTomorrow.members.findFirst[name.equals(itemName+"Tomorrow")].postUpdate(transform("VAT", "DK", value.toString))
        }
        else if (dateStr == today.format(dateFormatter)){
            gEnergiDataServiceToday.members.findFirst[name.equals(itemName+"Today")].postUpdate(transform("VAT", "DK", value.toString))
        }
    ]
    if (!isTmrPriceAvailable) {
        gEnergiDataServiceTomorrow.members.forEach[ item | 
            item.postUpdate(UNDEF)
        ]
        logInfo("EnergiDataService", "Reset tomorrow's electricity price to UNDEF")
    } else if (!isTmrPriceDefined) {
        logInfo("EnergiDataService", "Received tomorrow's electricity prices")
        sendNotification("xxxxxx", "Electricity for tomorrow is delivered at " + String.format("%1$tH:%1$tM", now))
    }
end
2 Likes

Hi.

I’ve been trying to make this binding for my OH 3.4 instance but struggling a little to build, as I have not done this before directly from the openhab-addons repo. Perhaps you can point me in the right direction.

I’m using VSC on a windows machine - I have maven installed and can build the Z-wave binding which I have, but from another repo.

What I have tried:
1 - download only the energidataservice binding folder. Failed to build - something with dependecies not being found.

2 - Fork the entire openhab-addons repo from the main branch - which does not include your binding. Copying your binding into that repo, and try and build. This showed the followinng message (I have not included all dependencies, but there are some 30-50 with the same absent message:

Could not resolve dependencies for project org.openhab.addons.bundles:org.openhab.binding.energidataservice:jar:4.0.0-SNAPSHOT: The following artifacts could not be resolved: org.openhab.core.bundles:org.openhab.core.test:jar:4.0.0-SNAPSHOT (absent)

3 - I then tried to change the pom.xml file where I changed the version to what I am currently using:

  <parent>
    <groupId>org.openhab.addons.bundles</groupId>
    <artifactId>org.openhab.addons.reactor.bundles</artifactId>
    <version>3.4.3-SNAPSHOT</version>
  </parent>

this then gave the following build error message (again only the first dependecy is shown - the list contains the same 30-50 dependencies - all with the same message):

Could not resolve dependencies for project org.openhab.addons.bundles:org.openhab.binding.energidataservice:jar:4.0.0-SNAPSHOT: The following artifacts could not be resolved: org.openhab.core.bundles:org.openhab.core.test:jar:4.0.0-SNAPSHOT (present)

I am running the release build of OH 3.4.3 on my RPi, but should this be an issue?

Hope you can help point me in the right direction
BR
Mark

The branch jlaur:14222-energidataservice is targeting the main branch, i.e. openHAB 4.0. It requires Java 17 as well as Gson 2.10. Therefore you cannot build it for 3.4.

I have backported it to a private branch. You can find a JAR that can be used directly with openHAB 3.4 here: Energi Data Service Binding [3.4.0.0;4.0.0.0)

You can also install it straight from the UI under Community Add-ons.

Thanks - I have no clue as to why I didn’t just check the UI first :person_facepalming: :laughing:

Just want to report in the past week the binding works flawlessly for me. Thank you for the great effort @laursen !
I received next day’s EL price every day at 13:00 - it is a big improvement over NordPool which I sometimes experience some delay. Maybe a small improvement suggestion: in case the price for next day is delivered earlier (NordPool sometimes delivers prices already at 12:40), it would be nice to trigger an update of HourlyPrices - instead of always update the item hourly.
The calculation for the cheapest period for charging my car also works perfect. The only issue I found is sometimes when I create an Instant for midnight, if I don’t set nanoseconds it doesn’t return a period for charging - I think maybe it’s because when nanoseconds > 0 it consider a new day and hence the algorithm doesn’t work to find the cheapest period. Anyways it’s easy fix :slight_smile:

Thanks for reporting back, I’m glad to hear it’s working as expected. :slight_smile:

All channels are updated as soon as new prices are available in the binding. However, since the prices are not guaranteed to be available before 13:00, the binding won’t try to fetch them before that time. In fact, I even add a small amount “jitter”, i.e. a random amount of time, so that you will receive the update between 13:00 and 13:01. This is to ensure that everyone will not call the service at the exact same time.

I know that prices are often available a little before 13:00. However, I’m afraid that trying to fetch them before the official availability time will only lead to more calls when they are not yet available, because the binding would then have to retry.

So even though you see hourly updates, in fact the binding only calls the service one time per day. The prices are then cached, and a scheduled job will update the channels accordingly each hour.

Is it a real problem waiting until 13:00-13:01, or only an observation? The time is kind of arbitrary, so for automations it probably shouldn’t make much of a difference waiting up to 20 minutes too much for next day’s prices. I understand though (believe me) that it can be slightly annoying waiting until 13:00 when getting the idea to check the prices at 12:50 and knowing they are probably available already, but that’s more a psychological problem. :wink:

Can you paste your rule code, then I’ll check that?

Looks like today there has been some problem with prices for tomorrow - now it’s 14:05 but it still hasn’t come. Do you mean you only try to call the service once per day? Does it mean if the delivery from NordPool is delayed after 13:00, the binding will never update tomorrow’s price (seems like my observation today)?
On a separate note: wouldn’t be a good idea to update the channels when the binding receives tomorrow’s price immediately (instead of caching and update per hourly schedule)?
Have a nice weekend!

Yes, I can see that:

2023-05-26 13:00:46.289 [TRACE] [gidataservice.internal.ApiController] - GET request for https://api.energidataservice.dk/dataset/Elspotprices?start=utcnow&filter=%7B%22PriceArea%22%3A%22DK1%22%7D&columns=HourUTC%2CSpotPriceDKK
2023-05-26 13:00:49.531 [TRACE] [gidataservice.internal.ApiController] - Response content: '{"total":13,"filters":"{\"PriceArea\":\"DK1\"}","dataset":"Elspotprices","records":[{"HourUTC":"2023-05-26T21:00:00","SpotPriceDKK":689.130005},{"HourUTC":"2023-05-26T20:00:00","SpotPriceDKK":741.280029},{"HourUTC":"2023>
2023-05-26 13:00:49.561 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Price update job rescheduled in 3550439 milliseconds
2023-05-26 13:00:49.573 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Refresh job rescheduled in 706 seconds: 2023-05-26T11:12:35.573561Z

So the call was successful, but we didn’t get new prices for tomorrow, and therefore it was rescheduled for being tried again 13:12:35:

2023-05-26 13:12:35.575 [TRACE] [gidataservice.internal.ApiController] - GET request for https://api.energidataservice.dk/dataset/Elspotprices?start=utcnow&filter=%7B%22PriceArea%22%3A%22DK1%22%7D&columns=HourUTC%2CSpotPriceDKK
2023-05-26 13:12:36.162 [TRACE] [gidataservice.internal.ApiController] - Response content: '{"total":12,"filters":"{\"PriceArea\":\"DK1\"}","dataset":"Elspotprices","records":[{"HourUTC":"2023-05-26T21:00:00","SpotPriceDKK":689.130005},{"HourUTC":"2023-05-26T20:00:00","SpotPriceDKK":741.280029},{"HourUTC":"2023>
2023-05-26 13:12:36.190 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Price update job rescheduled in 2843810 milliseconds
2023-05-26 13:12:36.193 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Refresh job rescheduled in 1316 seconds: 2023-05-26T11:34:32.192835Z

Same situation, again scheduled for 13:34:32:

2023-05-26 13:34:32.194 [TRACE] [gidataservice.internal.ApiController] - GET request for https://api.energidataservice.dk/dataset/Elspotprices?start=utcnow&filter=%7B%22PriceArea%22%3A%22DK1%22%7D&columns=HourUTC%2CSpotPriceDKK
2023-05-26 13:34:32.823 [TRACE] [gidataservice.internal.ApiController] - Response content: '{"total":12,"filters":"{\"PriceArea\":\"DK1\"}","dataset":"Elspotprices","records":[{"HourUTC":"2023-05-26T21:00:00","SpotPriceDKK":689.130005},{"HourUTC":"2023-05-26T20:00:00","SpotPriceDKK":741.280029},{"HourUTC":"2023>
2023-05-26 13:34:32.849 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Price update job rescheduled in 1527152 milliseconds
2023-05-26 13:34:32.850 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Refresh job rescheduled in 2600 seconds: 2023-05-26T12:17:52.850701Z

Same situation, again scheduled for 14:17:52:

2023-05-26 14:17:52.851 [TRACE] [gidataservice.internal.ApiController] - GET request for https://api.energidataservice.dk/dataset/Elspotprices?start=utcnow&filter=%7B%22PriceArea%22%3A%22DK1%22%7D&columns=HourUTC%2CSpotPriceDKK
2023-05-26 14:17:53.503 [TRACE] [gidataservice.internal.ApiController] - Response content: '{"total":11,"filters":"{\"PriceArea\":\"DK1\"}","dataset":"Elspotprices","records":[{"HourUTC":"2023-05-26T21:00:00","SpotPriceDKK":689.130005},{"HourUTC":"2023-05-26T20:00:00","SpotPriceDKK":741.280029},{"HourUTC":"2023>
2023-05-26 14:17:53.530 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Price update job rescheduled in 2526471 milliseconds
2023-05-26 14:17:53.531 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Refresh job rescheduled in 5625 seconds: 2023-05-26T13:51:38.531423Z

Still no new prices, next retry 15:51:38. And now finally:

2023-05-26 15:51:45.476 [TRACE] [gidataservice.internal.ApiController] - GET request for https://api.energidataservice.dk/dataset/Elspotprices?start=utcnow&filter=%7B%22PriceArea%22%3A%22DK1%22%7D&columns=HourUTC%2CSpotPriceDKK
2023-05-26 15:51:54.713 [TRACE] [gidataservice.internal.ApiController] - Response content: '{"total":34,"filters":"{\"PriceArea\":\"DK1\"}","dataset":"Elspotprices","records":[{"HourUTC":"2023-05-27T21:00:00","SpotPriceDKK":705.489990},{"HourUTC":"2023-05-27T20:00:00","SpotPriceDKK":745.109985},{"HourUTC":"2023>
2023-05-26 15:51:57.787 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Price update job rescheduled in 482213 milliseconds
2023-05-26 15:51:57.795 [DEBUG] [nal.handler.EnergiDataServiceHandler] - Refresh job rescheduled in 76123 seconds: 2023-05-27T11:00:40.794798Z

This time we received all the prices expected, so next call with be 13:00:40 tomorrow.

If the call is successful and we get tomorrow’s prices as expected, yes, then no further calls will be made. If the call fails, or if we didn’t get the expected prices for tomorrow, there will be further attempts. The time until next attempt depends on the situation, but in both cases there is an exponential back-off strategy with different parameters (aggresiveness).

No, it never gives up. There are properties available allowing you to track the status:

The internal cache and the channel hourly-prices are updated immediately when new data is received. The current price (e.g. channel spot-price) is updated each hour when the current price changes. In the future, when this work is finished:

I will update the binding so that future prices are also pushed immediately, so that they can be persisted.

The same to you!

For me DK2 prices were updated between 14:00 and 15:00, and the HourlyPrices were changed at 15:00. I don’t know when the binding receives the price though.
I noticed https://elspotpris.dk have tomorrow price delivered before 14:00 though (so NordPool has the prices before 14:00 and EnergiDataService for some reason is a bit later). I don’t know why DK1 prices you query came at first around 16:00, sounds a bit strange to me that DK1 and DK2 were not delivered at the same time - or maybe some other factors that caused us getting prices at different time

Delete.

It could be the same for me:

  • 14:17:52: Not yet available.
  • 15:51:38: Available.

There were no retries in between because of the exponential back-off strategy. So most likely you got lucky and received prices between 14:17:52 and 15:00:00.

They are different services, so it’s hard to say. If NordPool had issues today, all services would be affected, but in different ways depending on their implementations (for example retry mechanisms and internal data processing).

1 Like

There is something I don’t get - based on the log file (below) it looks like I already got the prices at 15:00. This is the time when the item HourlyPrice is updated

2023-05-26 15:00:00.449 [INFO ] [.core.model.script.EnergiDataService] - Tomorrow electricity price: 
	00-06: 1.15kr/kWh
	06-12: 0.92kr/kWh
	12-17: 0.43kr/kWh
	17-21: 1.74kr/kWh
	21-00: 1.39kr/kWh

However based on events log, I don’t receive any price until 15:22:

2023-05-26 15:00:00.005 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HourlyPrices' changed from [{"hourStart":"2023-05-26T00:00:00Z","spotPrice":0.45048999,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T01:00:00Z","spotPrice":0.030469999,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T02:00:00Z","spotPrice":0.012000,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T03:00:00Z","spotPrice":0.164289993,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T04:00:00Z","spotPrice":0.763130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T05:00:00Z","spotPrice":0.767900024,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T06:00:00Z","spotPrice":0.707840027,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T07:00:00Z","spotPrice":0.558080017,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T08:00:00Z","spotPrice":0.287160004,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T09:00:00Z","spotPrice":0.029950001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T10:00:00Z","spotPrice":0.030170,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T11:00:00Z","spotPrice":0.007230,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T12:00:00Z","spotPrice":0.000000,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T13:00:00Z","spotPrice":0.000520,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T14:00:00Z","spotPrice":0.070180,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T15:00:00Z","spotPrice":0.321250,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T16:00:00Z","spotPrice":0.602710022,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T17:00:00Z","spotPrice":0.620289978,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T18:00:00Z","spotPrice":0.84073999,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T19:00:00Z","spotPrice":0.81951001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T20:00:00Z","spotPrice":0.741280029,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T21:00:00Z","spotPrice":0.689130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000}] to [{"hourStart":"2023-05-26T01:00:00Z","spotPrice":0.030469999,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T02:00:00Z","spotPrice":0.012000,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T03:00:00Z","spotPrice":0.164289993,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T04:00:00Z","spotPrice":0.763130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T05:00:00Z","spotPrice":0.767900024,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T06:00:00Z","spotPrice":0.707840027,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T07:00:00Z","spotPrice":0.558080017,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T08:00:00Z","spotPrice":0.287160004,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T09:00:00Z","spotPrice":0.029950001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T10:00:00Z","spotPrice":0.030170,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T11:00:00Z","spotPrice":0.007230,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T12:00:00Z","spotPrice":0.000000,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T13:00:00Z","spotPrice":0.000520,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T14:00:00Z","spotPrice":0.070180,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T15:00:00Z","spotPrice":0.321250,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T16:00:00Z","spotPrice":0.602710022,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T17:00:00Z","spotPrice":0.620289978,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T18:00:00Z","spotPrice":0.84073999,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T19:00:00Z","spotPrice":0.81951001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T20:00:00Z","spotPrice":0.741280029,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T21:00:00Z","spotPrice":0.689130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000}]
2023-05-26 15:22:27.687 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HourlyPrices' changed from [{"hourStart":"2023-05-26T01:00:00Z","spotPrice":0.030469999,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T02:00:00Z","spotPrice":0.012000,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T03:00:00Z","spotPrice":0.164289993,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T04:00:00Z","spotPrice":0.763130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T05:00:00Z","spotPrice":0.767900024,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T06:00:00Z","spotPrice":0.707840027,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T07:00:00Z","spotPrice":0.558080017,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T08:00:00Z","spotPrice":0.287160004,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T09:00:00Z","spotPrice":0.029950001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T10:00:00Z","spotPrice":0.030170,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T11:00:00Z","spotPrice":0.007230,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T12:00:00Z","spotPrice":0.000000,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T13:00:00Z","spotPrice":0.000520,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T14:00:00Z","spotPrice":0.070180,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T15:00:00Z","spotPrice":0.321250,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T16:00:00Z","spotPrice":0.602710022,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T17:00:00Z","spotPrice":0.620289978,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T18:00:00Z","spotPrice":0.84073999,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T19:00:00Z","spotPrice":0.81951001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T20:00:00Z","spotPrice":0.741280029,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T21:00:00Z","spotPrice":0.689130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000}] to [{"hourStart":"2023-05-26T01:00:00Z","spotPrice":0.030469999,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T02:00:00Z","spotPrice":0.012000,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T03:00:00Z","spotPrice":0.164289993,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T04:00:00Z","spotPrice":0.763130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T05:00:00Z","spotPrice":0.767900024,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T06:00:00Z","spotPrice":0.707840027,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T07:00:00Z","spotPrice":0.558080017,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T08:00:00Z","spotPrice":0.287160004,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T09:00:00Z","spotPrice":0.029950001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T10:00:00Z","spotPrice":0.030170,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T11:00:00Z","spotPrice":0.007230,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T12:00:00Z","spotPrice":0.000000,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T13:00:00Z","spotPrice":0.000520,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T14:00:00Z","spotPrice":0.070180,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T15:00:00Z","spotPrice":0.321250,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T16:00:00Z","spotPrice":0.602710022,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T17:00:00Z","spotPrice":0.620289978,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T18:00:00Z","spotPrice":0.84073999,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T19:00:00Z","spotPrice":0.81951001,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T20:00:00Z","spotPrice":0.741280029,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T21:00:00Z","spotPrice":0.689130005,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T22:00:00Z","spotPrice":0.668090027,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-26T23:00:00Z","spotPrice":0.622210022,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T00:00:00Z","spotPrice":0.631150024,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T01:00:00Z","spotPrice":0.643059998,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T02:00:00Z","spotPrice":0.679710022,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T03:00:00Z","spotPrice":0.670400024,"spotPriceCurrency":"DKK","netTariff":0.150900,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T04:00:00Z","spotPrice":0.61602002,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T05:00:00Z","spotPrice":0.618190002,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T06:00:00Z","spotPrice":0.540869995,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T07:00:00Z","spotPrice":0.410140015,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T08:00:00Z","spotPrice":0.121639999,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T09:00:00Z","spotPrice":0.011020,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T10:00:00Z","spotPrice":0.000000,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T11:00:00Z","spotPrice":-0.017209999,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T12:00:00Z","spotPrice":-0.014530,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T13:00:00Z","spotPrice":0.002980,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T14:00:00Z","spotPrice":0.016830,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T15:00:00Z","spotPrice":0.410290009,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T16:00:00Z","spotPrice":0.632039978,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T17:00:00Z","spotPrice":0.747719971,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T18:00:00Z","spotPrice":0.930590027,"spotPriceCurrency":"DKK","netTariff":0.588700,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T19:00:00Z","spotPrice":0.842320007,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T20:00:00Z","spotPrice":0.745109985,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000},{"hourStart":"2023-05-27T21:00:00Z","spotPrice":0.70548999,"spotPriceCurrency":"DKK","netTariff":0.226400,"systemTariff":0.054000,"electricityTax":0.008000,"transmissionNetTariff":0.058000}]

The only explanation I have is:

  1. The binding already got the prices for tomorrow some time between 14-15, and it cached them.
  2. At 15:00 the binding updated the HourlyPrices to next hour, but for some reason it didn’t include prices for tomorrow (not sure why).
  3. My rule was triggered when HourlyPrices changed at 15:00 (2). It used the action “var priceMap = actions.getPrices(null)” which got the prices from the cache
  4. At 15:22 the binding updated HourlyPrices for tomorrow

If my above assumption is right: the binding seemed to know prices for tomorrow already at 15:00 (or before), however it didn’t update HourlyPrices until 15:22. Ideally I’d hope the binding update HourlyPrices immediately when it receives new prices for tomorrow.

The logs you posted are pretty clear: You received spot prices at 15:22.

I checked my logs also, and it’s similar, just 15:52:

2023-05-26 13:00:02.588 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_HourlyPrices' changed from [...] to [{"hourStart":"2023-05-25T23:00:00Z",[...]{"hourStart":"2023-05-26T21:00:00Z",[...]
2023-05-26 13:00:49.564 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_HourlyPrices' changed from [...] to [{"hourStart":"2023-05-25T23:00:00Z",[...]{"hourStart":"2023-05-26T21:00:00Z",[...]
2023-05-26 14:00:00.044 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_HourlyPrices' changed from [...] to [{"hourStart":"2023-05-26T00:00:00Z",[...]{"hourStart":"2023-05-26T21:00:00Z",[...]
2023-05-26 15:00:01.495 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_HourlyPrices' changed from [...] to [{"hourStart":"2023-05-26T01:00:00Z",[...]{"hourStart":"2023-05-26T21:00:00Z",[...]
2023-05-26 15:52:03.843 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_HourlyPrices' changed from [...] to [{"hourStart":"2023-05-26T01:00:00Z",[...]{"hourStart":"2023-05-27T21:00:00Z",[...]

The only unexpected thing in my logs is that the channel was updated 13:00:49 after failing to receive next day’s spot prices. I checked differences and found new slightly changed spot prices:

{"hourStart":"2023-05-26T14:00:00Z","spotPrice":0.070190002 (from)
{"hourStart":"2023-05-26T14:00:00Z","spotPrice":0.070180 (to)
{"hourStart":"2023-05-26T15:00:00Z","spotPrice":0.321290009 (from)
{"hourStart":"2023-05-26T15:00:00Z","spotPrice":0.321250 (to)
etc.

I checked the payload received 25.05.2023 13:00:

{
	"total": 37,
	"filters": "{\"PriceArea\":\"DK1\"}",
	"dataset": "Elspotprices",
	"records": [
		{
			"HourUTC": "2023-05-26T21:00:00",
			"SpotPriceDKK": 689.219971
		},

and the payload received 26.05.2023 13:00:

{
	"total": 13,
	"filters": "{\"PriceArea\":\"DK1\"}",
	"dataset": "Elspotprices",
	"records": [
		{
			"HourUTC": "2023-05-26T21:00:00",
			"SpotPriceDKK": 689.130005
		},

So prices are apparently not fully settled. This is news to me, and important for the upcoming future persistence update. However, it works as expected.

What might be slightly confusing in your case is that the hourly-prices channel is based on the keys for the spot prices, so when there is no spot price for a specific hour, other prices (like net tariff) will not be included either, even is cached.

However, the action getPrices(null) will merge all cached prices, so since net tariffs were available even when spot prices were not, the calculated sums would be missing the spot price element. I consider this a bug. In case the spot price is included as element, it should be required data for each returned key.

Hi @laursen
Thank you for your reply and sorry to keep chasing on this. Based on my log, it seems to know the spot price (and other fees) already at 15:00:00 despite that the hourly-prices channel was updated at 15:22. I have double check the avg prices in different periods, and all results look right to me. This basically means in my case the binding must know all prices for tomorrow already at 15:00:00 if not earlier.

2023-05-26 15:00:00.449 [INFO ] [.core.model.script.EnergiDataService] - Tomorrow electricity price:
00-06: 1.15kr/kWh
06-12: 0.92kr/kWh
12-17: 0.43kr/kWh
17-21: 1.74kr/kWh
21-00: 1.39kr/kWh

BTW I can confirm I also received 2 HourlyPrices updates at 13:00 today, with around 25 seconds interval.

No problem at all, one issue was already identified, and I’d rather investigate one thing too much than one thing too little - we need this to be stable and a source of truth.

To pinpoint this issue, we would need the problem to repeat itself, and you would need to provide more detailed logs. You can enable trace logging with the console command log:set trace org.openhab.binding.energidataservice. It should not spam your logs much, it will only add to the log each hour and when actually calling the service, in which case the full response payload will be logged.

I think this could have something to do with changes in currency exchange rates, since we are receiving data in DKK. So most likely the spot prices are fixed, but the conversion to DKK can change over time.

This is expected. At 13:00:00 the channel will be updated due to expiration of the oldest price, and seconds later there will (usually) be new prices available, which will add new hours, so the channel will once again be updated. The unexpected thing for me today was that it was updated in a situation where the new prices actually were not received. But this is now known to be caused by slight spot price changes.

I double-checked the code, and I was mistaken. The action is also based on the spot price when this is included as element. So no bug here after all.

@somy - now would be a good time to enable trace logging. It was announced that upgrades at Energinet can cause instability and delayed data until tomorrow or Monday. I can also see that prices for tomorrow are not yet available.

Additionally, I have enabled hourly logging of the spot prices payload through the HTTP binding to try to find a pattern when existing prices are updated.