Repository navigation
electricity pricing: if last price key is before next calculated query time set last price key as query time - #3458
Merged
LKuemmel merged 5 commits intoJun 3, 2026
Conversation
…ry time set last price key as query time
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the electricity pricing refresh scheduling so that when the currently stored price list ends before the next planned update window, the next query is moved forward to align with the last available price timestamp (rather than waiting until the next configured tariff update hour).
Changes:
- Refactors next-query-time calculation to accept the latest available price timestamp and potentially schedule earlier updates.
- Updates the component updater flow to pass the latest price timestamp into the scheduling logic.
- Adds unit tests to validate the next-query-time calculation behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/modules/common/configurable_tariff.py | Updates next query scheduling logic to consider latest price timestamp. |
| packages/modules/common/configurable_tariff_test.py | Adds tests for the new next query time behavior and updates private-method test calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+84
to
+89
| if latest_price_timestamp < next_query_time: | ||
| # Falls die Preise nicht bis zum nächsten geplanten Abruf gültig sind, | ||
| # den Abruf auf die Gültigkeitsdauer der Preise setzen | ||
| log.debug(f"Die Preise sind nur bis {latest_price_timestamp} gültig, " | ||
| f"setze nächsten Abruf auf dieses Datum.") | ||
| next_query_time = latest_price_timestamp |
Comment on lines
+96
to
+100
| last_known_timestamp = datetime.fromtimestamp(int(max(self.get.prices.keys()) if self.get.prices else 0)) | ||
| tariff_state = self._component_updater() | ||
| if last_known_timestamp < datetime.fromtimestamp(int(max(tariff_state.prices.keys()))): | ||
| self.__calculate_next_query_time() | ||
| latest_price_timestamp = datetime.fromtimestamp( | ||
| int(max(tariff_state.prices.keys()) if tariff_state.prices else 0)) | ||
| if last_known_timestamp < latest_price_timestamp: |
Comment on lines
+88
to
+89
| if next_query_time <= now: | ||
| next_query_time += timedelta(hours=1) | ||
| next_query_time = now + timedelta(hours=1) |
Comment on lines
+165
to
+172
| latest_price_timestamp = datetime(2022, 5, 16, 12, 30, 0) | ||
|
|
||
| # execution | ||
| tariff._calculate_next_query_time(latest_price_timestamp) # pyright: ignore[reportPrivateUsage] | ||
|
|
||
| # evaluation | ||
| expected_timestamp = int(latest_price_timestamp.timestamp()) | ||
| assert tariff.get.next_query_time == expected_timestamp |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
LKuemmel
marked this pull request as ready for review
June 3, 2026 07:50
ndrsnhs
pushed a commit
to ndrsnhs/core
that referenced
this pull request
Aug 24, 2026
…y time set last price key as query time (openWB#3458) * electricity pricing_: if last price key is before next calculated query time set last price key as query time * fix * review * review * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://forum.openwb.de/viewtopic.php?p=144339#p144339