Skip to content

fix: reset shutdown grace period when significant charging stops#431

Merged
nanomad merged 2 commits intoSAIC-iSmart-API:developfrom
nanomad:fix/charging-state-shutdown-detection
Mar 13, 2026
Merged

fix: reset shutdown grace period when significant charging stops#431
nanomad merged 2 commits intoSAIC-iSmart-API:developfrom
nanomad:fix/charging-state-shutdown-detection

Conversation

@nanomad
Copy link
Contributor

@nanomad nanomad commented Mar 13, 2026

Summary

Closes #315

  • Convert is_charging to a property that detects True→False transitions and resets last_car_shutdown, triggering the after_shutdown grace period (~120s polling for ~600s)
  • Only reset when significant charging power (>1kW) was observed during the session, preventing oscillation from OBC trickle/maintenance draws that could drain the 12V battery
  • Add tests for is_charging transition behavior, polling phase publishing, and the end-to-end charging-stop-to-grace-period flow

Root cause: When charging stopped (e.g. 3p→1p phase switch), hv_battery_active_from_car was already False (car parked), so last_car_shutdown was never updated. The gateway skipped the after_shutdown grace period and fell straight to inactive (24h polling), missing the charger reconnection.

Test plan

  • Verify is_charging True→False with significant power resets last_car_shutdown
  • Verify is_charging True→False without significant power does NOT reset
  • Verify after a real charge session stops, gateway enters after_shutdown polling phase
  • Verify OBC trickle charging oscillation does not cause indefinite polling

🤖 Generated with Claude Code

nanomad and others added 2 commits March 13, 2026 19:43
…C-iSmart-API#315)

When is_charging transitions True→False, reset last_car_shutdown so the
gateway enters the after_shutdown grace period and polls frequently to
detect charger reconnection (e.g. after a 3-phase to 1-phase switch).

Only trigger the reset if significant charging power (>1kW) was observed,
to avoid oscillation from OBC trickle/maintenance draws that could keep
the gateway polling indefinitely and drain the 12V battery.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When charging with insignificant power (<1kW, e.g. OBC trickle), set
refresh_period_charging to at least refresh_period_after_shutdown (120s)
to prevent falling through to the active polling rate (30s) indefinitely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nanomad nanomad force-pushed the fix/charging-state-shutdown-detection branch from 58cbe2f to 4a6c27e Compare March 13, 2026 18:53
@nanomad nanomad merged commit b819be3 into SAIC-iSmart-API:develop Mar 13, 2026
0 of 3 checks 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.

1 participant