Skip to content

[energidataservice] Add support for hourly spot prices as calculated average - #19553

Merged
lsiepel merged 1 commit into
openhab:mainfrom
jlaur:energidataservice-hourly-spot-prices
May 24, 2026
Merged

[energidataservice] Add support for hourly spot prices as calculated average#19553
lsiepel merged 1 commit into
openhab:mainfrom
jlaur:energidataservice-hourly-spot-prices

Conversation

@jlaur

@jlaur jlaur commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

This is configurable on Thing level, and will affect the spot-price channel as well as calculated results from Thing actions.

@jlaur jlaur added enhancement An enhancement or new feature for an existing add-on additional testing preferred The change works for the pull request author. A test from someone else is preferred though. labels Oct 25, 2025
@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch from ee02cd5 to 99ba903 Compare November 6, 2025 20:05
@jlaur jlaur added work in progress A PR that is not yet ready to be merged and removed additional testing preferred The change works for the pull request author. A test from someone else is preferred though. labels Nov 23, 2025
@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch 2 times, most recently from 5f870b1 to eebba21 Compare December 22, 2025 15:34
@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch 4 times, most recently from ba419b0 to fe38d90 Compare January 30, 2026 20:52
@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch from fe38d90 to df2b070 Compare March 12, 2026 21:32
@lsiepel
lsiepel requested a review from Copilot April 28, 2026 07:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional Thing-level configuration to expose spot prices as an hourly average (derived from quarter-hourly values), affecting both the spot-price channel and price calculations performed by Thing actions.

Changes:

  • Introduces a new Thing parameter hourlySpotPrices (UI config + i18n + README).
  • Extends SpotPriceSubscription to include an hourly-average variant.
  • Updates ElectricityPriceProvider and caches to support recalculating and serving hourly-average spot prices.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/i18n/energidataservice.properties Adds i18n label/description for the new hourlySpotPrices Thing parameter.
bundles/org.openhab.binding.energidataservice/src/main/resources/OH-INF/config/service.xml Adds the hourlySpotPrices boolean Thing configuration parameter.
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/provider/subscription/SpotPriceSubscription.java Adds hourly-average flag to distinguish subscription variants.
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/provider/cache/SubscriptionDataCache.java Extends cache API to support replacing cached key/value pairs.
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/provider/cache/ElectricityPriceSubscriptionCache.java Implements replacing the internal cached price map.
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/provider/ElectricityPriceProvider.java Adds hourly-average recalculation logic and cache dependency handling.
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/handler/EnergiDataServiceHandler.java Creates spot-price subscriptions using the new Thing config flag.
bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/config/EnergiDataServiceConfiguration.java Adds new config field mapping hourlySpotPrices.
bundles/org.openhab.binding.energidataservice/README.md Documents the new Thing configuration parameter.
Comments suppressed due to low confidence (1)

bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/provider/subscription/SpotPriceSubscription.java:54

  • hashCode() still only hashes priceArea and currency even though equality now also depends on hourlyAverage. Consider including hourlyAverage in hashCode() as well to keep it aligned with equals() and avoid unnecessary hash collisions in maps/sets keyed by this subscription.
    @Override
    public int hashCode() {
        return Objects.hash(priceArea, currency);
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bundles/org.openhab.binding.energidataservice/README.md Outdated
@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch from df2b070 to 64139e9 Compare April 28, 2026 21:05
@lsiepel

lsiepel commented May 16, 2026

Copy link
Copy Markdown
Contributor

@jlaur if not mistaken you liked to have this into 5.2. Ping when you are ready for a final review.

@jlaur

jlaur commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

if not mistaken you liked to have this into 5.2. Ping when you are ready for a final review.

Thanks, I should try to prioritize this soon. The main reason why it has been "work in progress" for so long is that the current cache implementation is not prepared for this change. In the current implementation, the calculated hourly prices are added as a "sidecar", but this complicates things a bit, so I already started a rewrite. Secondly, Copilot found a real issue with possible loss of events.

@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch 3 times, most recently from c3dccbd to 0bc8e4f Compare May 18, 2026 19:36
@jlaur

jlaur commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Secondly, Copilot found a real issue with possible loss of events.

OK, delegated to Claude, result looks good. Will let it run until tomorrow's day-ahead prices becomes available, then I should be able to confirm and publish the PR in its current form (without major cache refactoring).

@jlaur
jlaur marked this pull request as ready for review May 19, 2026 17:11
@jlaur jlaur removed the work in progress A PR that is not yet ready to be merged label May 19, 2026
@jlaur

jlaur commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

@lsiepel - this is now ready for review. I don't know when I'll find the time to rewrite the cache, but in any case that will have to be in another PR. The current "sidecar" approach has been tested for quite a while now, and the event issue is fixed as well, and has been successfully tested now for some days.

@lsiepel
lsiepel requested a review from Copilot May 24, 2026 18:32

@lsiepel lsiepel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur
jlaur force-pushed the energidataservice-hourly-spot-prices branch from 0bc8e4f to 136b79a Compare May 24, 2026 20:50
@lsiepel
lsiepel merged commit 05c9fdf into openhab:main May 24, 2026
2 checks passed
@lsiepel lsiepel added this to the 5.2 milestone May 24, 2026
@jlaur
jlaur deleted the energidataservice-hourly-spot-prices branch May 24, 2026 21:48
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Jun 13, 2026
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
darkscout pushed a commit to darkscout/openhab-addons that referenced this pull request Jul 5, 2026
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
olemr pushed a commit to olemr/openhab2-addons that referenced this pull request Aug 8, 2026
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: olemr <olemr@olemr.com>
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this pull request Aug 16, 2026
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants