Skip to content

fix load default after unplug#3309

Merged
LKuemmel merged 3 commits intoopenWB:masterfrom
LKuemmel:fixes
Apr 20, 2026
Merged

fix load default after unplug#3309
LKuemmel merged 3 commits intoopenWB:masterfrom
LKuemmel:fixes

Conversation

@LKuemmel
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets chargepoint behavior when charging stops/unplug occurs, adjusting which EV data is referenced during unplug handling and changing when the active EV (charging_ev_data) is resolved during the main Chargepoint.update() cycle.

Changes:

  • Use data.data.ev_data[f"ev{...}"] lookups (f-strings) during _process_charge_stop() for chargelog and manual-SoC reset checks.
  • Move _get_charging_ev(vehicle, ev_list) inside the charging_possible branch in update().

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

Comment on lines +193 to +195
if (data.data.ev_data[f"ev{self.data.config.ev}"].soc_module is not None and
data.data.ev_data[f"ev{self.data.config.ev}"].soc_module.vehicle_config.type == "manual" and
data.data.ev_data[f"ev{self.data.config.ev}"].soc_module.vehicle_config.configuration.reset_after_unplug):
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

data.data.ev_data[f"ev{self.data.config.ev}"] is looked up three times in the same condition. Please assign it once to a local variable (e.g., ev = ...) and reference ev.soc_module... to reduce duplication and avoid inconsistencies if self.data.config.ev changes in the future (it is mutated later in this block when load_default is set).

Copilot uses AI. Check for mistakes.
Comment on lines 640 to +643

if charging_possible:
try:
charging_ev = self._get_charging_ev(vehicle, ev_list)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

By moving _get_charging_ev(vehicle, ev_list) inside if charging_possible, self.data.set.charging_ev_data is no longer updated on cycles where charging is blocked (e.g., manual lock/autolock while plugged). This object is still used later in update() (e.g., the SoC timestamp comparison against self.data.set.charging_ev_data.data.get.soc_timestamp), so it can become stale and reference the wrong EV. Consider calling _get_charging_ev before the charging_possible branch (as before) or otherwise ensuring charging_ev_data stays in sync with the resolved vehicle even when charging is not allowed.

Suggested change
if charging_possible:
try:
charging_ev = self._get_charging_ev(vehicle, ev_list)
charging_ev = self._get_charging_ev(vehicle, ev_list)
if charging_possible:
try:

Copilot uses AI. Check for mistakes.
Comment on lines 642 to 644
try:
charging_ev = self._get_charging_ev(vehicle, ev_list)
state, message_ev, submode, required_current, template_phases = charging_ev.get_required_current(
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This behavioral change in update() (deferring _get_charging_ev until charging_possible is true) doesn’t appear to be covered by existing tests (current chargepoint_test.py focuses on helpers and _process_charge_stop). Please add a regression test for the scenario the PR title mentions (load default after unplug) and/or a case where charging is not allowed while plugged, to ensure charging_ev_data and SoC update behavior remain correct.

Copilot uses AI. Check for mistakes.
@LKuemmel LKuemmel merged commit b2bbccb into openWB:master Apr 20, 2026
1 check passed
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