Skip to content

feat(EvseManager)!: restructure charging state machine to simplify pause/resume and remove replug#1790

Open
corneliusclaussen wants to merge 3 commits intomainfrom
refactor/charger-state-machine
Open

feat(EvseManager)!: restructure charging state machine to simplify pause/resume and remove replug#1790
corneliusclaussen wants to merge 3 commits intomainfrom
refactor/charger-state-machine

Conversation

@corneliusclaussen
Copy link
Contributor

@corneliusclaussen corneliusclaussen commented Feb 4, 2026

Describe your changes

Remove WaitingForEnergy, Replug states and related session events (ChargingResumed, ReplugStarted, ReplugFinished, WaitingForEnergy). Consolidate pause handling into ChargingPausedEVSE with reason tracking
(Error, NoEnergy, UserPause) via new PauseChargingEVSEReasonEnum.

Key changes in Charger state machine:

  • Replace WaitingForEnergy state with direct transitions through ChargingPausedEVSE, which now reports multiple concurrent reasons
  • Remove evse_replug command from BSP interface and all implementations
  • Remove EvseReplugStarted/Finished events from board_support_common
  • Add configurable hlc_charge_loop_without_energy_timeout_s for ISOsessions to handle no-energy scenarios gracefully in charge loop
  • Add dc_ramp_ampere_per_second config for DC current ramping
  • Change zero_power_ignore_pause default to true for better EV compatibility
  • Introduce StoppingCharging as proper transitional state that waits for contactor open before moving to paused or finished states
  • Use atomic flags (flag_authorized, flag_transaction_active, flag_ev_plugged_in, flag_paused_by_evse) for thread-safe state

BREAKING CHANGE: Removes WaitingForEnergy, ChargingResumed, ReplugStarted, ReplugFinished session events and evse_replug BSP command. Consumers must handle ChargingPausedEVSE with reason tracking instead.

Behavioral changes:

  • EvseManager will set state F in case no EV is plugged in and EvseManager has an active error
  • The default of zero_power_ignore_pause has been changed to true because this is more compatible with real EVs. With this configuration parameter being true DC sessions will reach the charge loop in case no energy is available before the session is stopped by the EVSE after hlc_charge_loop_without_energy_timeout_s
  • In general EVerest attempts to be able/ready to restart/resume ISO15118 sessions whenever possible in case of errors, no energy or user pause

Smoke tests:

  • Add pause/resume session commands to test controller interface
  • Add comprehensive smoke tests for pause/resume and no-energy scenarios
  • Remove deprecated startup_tests.py in favor of new probe-based tests

These changes have been verified within the following test scenarios with real EVs for basic charging, ISO15118-2 AC and DC

  • No energy available at start of session
  • No energy available during session
  • User pause during session
  • User resume during session
  • Raise error before session
  • Raise/clear error during session

NOTE: The main changes of this PR are located in Charger.cpp/hpp and EvseManager.cpp/hpp. Most of changes in the other files are due to the removed types, vars and interface commands.

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch from 963841d to d287068 Compare February 4, 2026 17:35
@FaHaGit
Copy link
Contributor

FaHaGit commented Feb 5, 2026

evse_replug cmd is still in the EvseBoardSupport interface. Shouldn't we just remove it if no one is using it anymore?

@Pietfried
Copy link
Contributor

evse_replug cmd is still in the EvseBoardSupport interface. Shouldn't we just remove it if no one is using it anymore?

Yes I guess we will eventually remove it. This PR is still an early draft

@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch 3 times, most recently from bc8c99d to b2942cf Compare February 8, 2026 16:44
@corneliusclaussen corneliusclaussen force-pushed the refactor/charger-state-machine branch from b2942cf to 43905b8 Compare February 9, 2026 07:34
@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch from afed9ab to 3bbc287 Compare February 12, 2026 11:04
@Pietfried Pietfried added the include-in-release Tag that this PR should be included in the current merge window for the upcoming release if possible label Feb 16, 2026
@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch from 3bbc287 to ef9d73c Compare February 18, 2026 17:36
@corneliusclaussen corneliusclaussen force-pushed the refactor/charger-state-machine branch 2 times, most recently from 0bab031 to b36221e Compare February 24, 2026 08:27
@corneliusclaussen corneliusclaussen marked this pull request as ready for review February 27, 2026 11:31
@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch from 6730bb3 to 367254c Compare February 27, 2026 11:32
@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch 3 times, most recently from ea171f4 to 9481e08 Compare February 27, 2026 15:17
@Pietfried Pietfried changed the title Refactor/charger state machine feat(evse_manager)!: restructure charging state machine to simplify pause/resume and remove replug Feb 27, 2026
@Pietfried Pietfried changed the title feat(evse_manager)!: restructure charging state machine to simplify pause/resume and remove replug feat(EvseManager)!: restructure charging state machine to simplify pause/resume and remove replug Feb 27, 2026
…ause/resume and remove replug

Remove WaitingForEnergy, Replug states and related session events
(ChargingResumed, ReplugStarted, ReplugFinished, WaitingForEnergy).
Consolidate pause handling into ChargingPausedEVSE with reason tracking
(Error, NoEnergy, UserPause) via new PauseChargingEVSEReasonEnum.

Key changes in Charger state machine:
- Replace WaitingForEnergy state with direct transitions through
  ChargingPausedEVSE, which now reports multiple concurrent reasons
- Remove evse_replug command from BSP interface and all implementations
- Remove EvseReplugStarted/Finished events from board_support_common
- Add configurable hlc_charge_loop_without_energy_timeout_s for ISO
  sessions to handle no-energy scenarios gracefully in charge loop
- Add dc_ramp_ampere_per_second config for DC current ramping
- Change zero_power_ignore_pause default to true for better EV compatibility
- Introduce StoppingCharging as proper transitional state that waits
  for contactor open before moving to paused or finished states
- Use atomic flags (flag_authorized, flag_transaction_active,
  flag_ev_plugged_in, flag_paused_by_evse) for thread-safe state

BREAKING CHANGE: Removes WaitingForEnergy, ChargingResumed,
ReplugStarted, ReplugFinished session events and evse_replug BSP
command. Consumers must handle ChargingPausedEVSE with reason
tracking instead.

Smoke tests:
- Add pause/resume session commands to test controller interface
- Add comprehensive smoke tests for pause/resume and no-energy scenarios
- Remove deprecated startup_tests.py in favor of new probe-based tests

Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
Signed-off-by: Cornelius Claussen <cc@pionix.de>
Signed-off-by: Sebastian Lukas <sebastian.lukas@pionix.de>
@Pietfried Pietfried force-pushed the refactor/charger-state-machine branch from 9481e08 to cdf3ce6 Compare February 27, 2026 15:32
@Pietfried
Copy link
Contributor

@barsnick Could you please review the changes in the RpcApi module? Unless you plan to find a workaround, the changes are breaking because we removed the WaitingForEnergy event. Can you help pointing to or updating the version accordingly?

Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
@barsnick
Copy link
Contributor

barsnick commented Mar 3, 2026

I'll have a look.

Signed-off-by: Sebastian Lukas <sebastian.lukas@pionix.de>
Copy link
Member

@SebaLukas SebaLukas left a comment

Choose a reason for hiding this comment

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

Looking very good 👍

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

Labels

include-in-release Tag that this PR should be included in the current merge window for the upcoming release if possible

Projects

None yet

6 participants