electricity pricing: fix update required, energycharts#3255
electricity pricing: fix update required, energycharts#3255LKuemmel wants to merge 4 commits intoopenWB:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts electricity pricing handling around EnergyCharts fetching and optional-module update/reset behavior, and hardens grid-fee/tariff price aggregation against missing/empty inputs.
Changes:
- Simplify EnergyCharts tariff fetching to a single HTTP request/parse path.
- Add
None-safety checks for optional module configs and return{}when both tariff and grid-fee price sets are empty (prevents crashes). - Ensure optional electricity-pricing state reset clears published prices/next-query-time consistently and refine “update required” logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/modules/electricity_pricing/flexible_tariffs/energycharts/tariff.py | Removes retry/backoff loop and uses a single request+parse flow for EnergyCharts prices. |
| packages/modules/common/store/_tariff.py | Adds None guards when reading optional module configs; prevents failure when both inputs are empty; minor formatting fix. |
| packages/control/optional.py | Makes _reset_state always publish cleared prices/next query time; changes logic determining whether a price update is required. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/control/optional.py
Outdated
| return ((self._flexible_tariff_module and | ||
| self._is_et_price_update_required_for_module(self.data.electricity_pricing.flexible_tariff)) or | ||
| (self._grid_fee_module and | ||
| self._is_et_price_update_required_for_module(self.data.electricity_pricing.grid_fee))) | ||
|
|
There was a problem hiding this comment.
et_price_update_required() currently uses self._flexible_tariff_module and ... / self._grid_fee_module and .... Because these attributes are objects (or None), the expression can return None (e.g., False or None -> None) instead of a bool, and it can also call _is_et_price_update_required_for_module() with module=None if _grid_fee_module is set but self.data.electricity_pricing.grid_fee is None (this is how existing tests model “no grid fee”). Please make this return a strict boolean and handle None modules safely (e.g., use is not None checks and/or reintroduce the module is None guard).
| return ((self._flexible_tariff_module and | |
| self._is_et_price_update_required_for_module(self.data.electricity_pricing.flexible_tariff)) or | |
| (self._grid_fee_module and | |
| self._is_et_price_update_required_for_module(self.data.electricity_pricing.grid_fee))) | |
| flexible_required = False | |
| if ( | |
| self._flexible_tariff_module is not None | |
| and self.data.electricity_pricing.flexible_tariff is not None | |
| ): | |
| flexible_required = self._is_et_price_update_required_for_module( | |
| self.data.electricity_pricing.flexible_tariff | |
| ) | |
| grid_required = False | |
| if ( | |
| self._grid_fee_module is not None | |
| and self.data.electricity_pricing.grid_fee is not None | |
| ): | |
| grid_required = self._is_et_price_update_required_for_module( | |
| self.data.electricity_pricing.grid_fee | |
| ) | |
| return flexible_required or grid_required |
| response.raise_for_status() | ||
| return parse_response(config, response.json()) | ||
|
|
||
|
|
||
| def create_electricity_tariff(config: EnergyChartsTariff): |
There was a problem hiding this comment.
fetch_prices() no longer uses the retry/backoff logic, but the module still defines MAX_RETRIES/MAX_DELAY and imports random, requests, and time, which are now unused. Please remove the unused constants/imports (or reintroduce the retry logic) to avoid linting/runtime maintenance issues.
|
@tpd-opitz Möchtest Du ein Review machen? |
Vielen Dank für das Vertrauen. Ich mache das sehr gern, aber ob ich vor Ostern noch Zeit dazu finde kann ich nicht versprechen. |
No description provided.