Skip to content

electricity pricing: update prices after config change - #3376

Merged
LKuemmel merged 4 commits into
openWB:masterfrom
LKuemmel:fix_electricity_pricing_update
Jun 9, 2026
Merged

LKuemmel merged 4 commits into
openWB:masterfrom
LKuemmel:fix_electricity_pricing_update

Conversation

@LKuemmel

@LKuemmel LKuemmel commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Ticket #66004415
Preise wurden nur beim Wechsel des Anbieters, aber nicht beim Ändern von Einstellungen aktualisiert.

@LKuemmel
LKuemmel requested a review from Copilot May 20, 2026 09:18
@LKuemmel LKuemmel added this to the 2.2.0-Patch.1 milestone May 20, 2026

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

Updates the electricity pricing module reset logic so price data is cleared and re-fetched when the flexible tariff or grid fee provider configuration changes, rather than only when the provider name changes.

Changes:

  • Changed flexible tariff module “config changed” detection from config.name comparison to comparing the full config object.
  • Changed grid fee module “config changed” detection from config.name comparison to comparing the full config object.
Comments suppressed due to low confidence (1)

packages/control/optional.py:61

  • Same issue as above: self._grid_fee_module.config != value.config will almost always be true for configs that don’t define __eq__, causing unnecessary resets/price clearing whenever the provider config topic is reprocessed. Use a stable config fingerprint or explicit field comparison (excluding volatile runtime fields) to decide when a reset is actually needed.
    def grid_fee_module(self, value: TypingOptional[ConfigurableGridFee]):
        if (value is None or
                (self._grid_fee_module and value and
                 self._grid_fee_module.config != value.config)):
            self.data.electricity_pricing.grid_fee.get = PricingGet()
            self._reset_state(self.data.electricity_pricing.grid_fee)

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

Comment on lines 43 to 47
if (value is None or
(self._flexible_tariff_module and value and
self._flexible_tariff_module.config.name != value.config.name)):
self._flexible_tariff_module.config != value.config)):
self.data.electricity_pricing.flexible_tariff.get = PricingGet()
self._reset_state(self.data.electricity_pricing.flexible_tariff)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Umstellung auf dataclasses für die config-Klassen und dann compare=False-Attribut benutzen.

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 12 out of 12 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

packages/modules/electricity_pricing/flexible_tariffs/voltego/config.py:9

  • expires_in and created_at are typed as Optional[str], but the implementation treats them as numeric seconds/timestamps (e.g. created_at + expires_in in voltego/tariff.py). Please change these annotations to numeric types (e.g. Optional[int]/Optional[float]) to match actual usage and avoid accidental string values breaking token validation.
class VoltegoToken:
    access_token: Optional[str] = field(default=None, compare=False, repr=False)  # don't show in UI
    expires_in: Optional[str] = field(default=None, compare=False)  # don't show in UI
    created_at: Optional[str] = field(default=None, compare=False)  # don't show in UI

Comment on lines +5 to 10
@dataclass
class VoltegoToken:
access_token: Optional[str] = field(default=None, compare=False, repr=False) # don't show in UI
expires_in: Optional[str] = field(default=None, compare=False) # don't show in UI
created_at: Optional[str] = field(default=None, compare=False) # don't show in UI

Comment on lines +5 to +11
@dataclass
class WestfalenWindToken:
access_token: Optional[str] = field(default=None, compare=False, repr=False) # don't show in UI
refresh_token: Optional[str] = field(default=None, compare=False, repr=False) # don't show in UI
token_type: Optional[str] = field(default=None, compare=False) # don't show in UI
expires: Optional[int] = field(default=None, compare=False) # don't show in UI
created_at: Optional[float] = field(default=None, compare=False) # don't show in UI

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 12 out of 12 changed files in this pull request and generated 4 comments.

Comment on lines +9 to +14
update_hours: list[int] = field(default_factory=lambda: [14]) # tibber publishes once daily before 14:00
'''
dynamische Netzentgelte müssen umgerechnet werden,
damit der Gesamtpreis nicht um den Normalpreis der Netzentgelte verzerrt wird.
'''
self.includes_grid_fee = True
includes_grid_fee: bool = True
Comment on lines +6 to +10
class FixedHoursTariffConfiguration:
def __init__(self,
default_price: float = 0,
tariffs: List[Dict[str, any]] = None,
update_hours: List[int] = None) -> None:
self.default_price = default_price
self.tariffs = tariffs if tariffs is not None else []
self.update_hours = update_hours if update_hours is not None else list(range(24))
'''
default_price: float = 0
tariffs: list[dict[str, Any]] = field(default_factory=list)
update_hours: list[int] = field(default_factory=lambda: list(range(24)))
'''
Comment on lines +6 to +9
class VoltegoToken:
access_token: Optional[str] = field(default=None, repr=False) # don't show in UI
expires_in: Optional[str] = field(default=None) # don't show in UI
created_at: Optional[str] = field(default=None) # don't show in UI
Comment on lines 42 to 46
def flexible_tariff_module(self, value: TypingOptional[ConfigurableFlexibleTariff]):
if (value is None or
(self._flexible_tariff_module and value and
self._flexible_tariff_module.config.name != value.config.name)):
self._flexible_tariff_module.config != value.config)):
self.data.electricity_pricing.flexible_tariff.get = PricingGet()
@LKuemmel
LKuemmel force-pushed the fix_electricity_pricing_update branch from 2bce9cd to 20acff2 Compare June 9, 2026 09:23
@LKuemmel
LKuemmel merged commit c062772 into openWB:master Jun 9, 2026
1 check passed
@LKuemmel
LKuemmel deleted the fix_electricity_pricing_update branch June 9, 2026 09:29
ndrsnhs pushed a commit to ndrsnhs/core that referenced this pull request Aug 24, 2026
* electricity pricing: update prices after config change

* use dataclasses for config classes

* review

* review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants