Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/control/chargepoint/chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,23 @@ def _process_charge_stop(self) -> None:
self.reset_control_parameter_at_charge_stop()
data.data.counter_all_data.get_evu_counter().reset_switch_on_off(self)
if self.data.get.plug_state is False and self.data.set.plug_state_prev is True:
chargelog.save_and_reset_data(self, data.data.ev_data["ev"+str(self.data.config.ev)])
charging_ev = data.data.ev_data[f"ev{self.data.config.ev}"]
chargelog.save_and_reset_data(self, charging_ev)
self.data.control_parameter = control_parameter_factory()
# VOR Standard nach Abstecken
if (self.data.set.charging_ev_data.soc_module is not None and
self.data.set.charging_ev_data.soc_module.vehicle_config.type == "manual" and
self.data.set.charging_ev_data.soc_module.vehicle_config.configuration.reset_after_unplug):
if (charging_ev.soc_module is not None and
charging_ev.soc_module.vehicle_config.type == "manual" and
charging_ev.soc_module.vehicle_config.configuration.reset_after_unplug):
Pub().pub(f"openWB/set/vehicle/{self.data.config.ev}/soc_module/calculated_soc_state/manual_soc", 0)
if self.data.set.charge_template.data.load_default:
self.data.config.ev = 0
if self.template.data.disable_after_unplug:
self.data.set.manual_lock = True
log.debug("/set/manual_lock True")
# NACH Standard nach Abstecken
ev_after_load_default = data.data.ev_data[f"ev{self.data.config.ev}"]
if data.data.general_data.data.temporary_charge_templates_active:
self.update_charge_template(
data.data.ev_data["ev"+str(self.data.config.ev)].charge_template)
self.update_charge_template(ev_after_load_default.charge_template)

self.data.set.rfid = None
self.data.set.plug_time = None
Expand Down Expand Up @@ -635,12 +636,12 @@ def update(self, ev_list: Dict[str, Ev]) -> None:
vehicle, message_ev = self.template.get_ev(self.data.set.rfid or self.data.get.rfid,
self.data.get.vehicle_id,
self.data.config.ev)
charging_ev = self._get_charging_ev(vehicle, ev_list)
if message_ev:
message += message_ev

if charging_possible:
try:
charging_ev = self._get_charging_ev(vehicle, ev_list)
Comment on lines 641 to +644

Copilot AI Apr 20, 2026

Copy link

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.
state, message_ev, submode, required_current, template_phases = charging_ev.get_required_current(
Comment on lines 643 to 645

Copilot AI Apr 20, 2026

Copy link

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.
self.data.set.charge_template,
self.data.control_parameter,
Expand Down
Loading