Skip to content

Detect trip start/end in GPS handler, not just watchdog #249

Merged
kvanbiesen merged 5 commits into
kvanbiesen:mainfrom
renaudallard:main
Feb 15, 2026
Merged

Detect trip start/end in GPS handler, not just watchdog #249
kvanbiesen merged 5 commits into
kvanbiesen:mainfrom
renaudallard:main

Conversation

@renaudallard

Copy link
Copy Markdown
Contributor

The GPS handler updated _last_derived_is_moving on state changes but
did not trigger _end_driving_session or _anchor_driving_session. The
watchdog (every 30s) had that logic but never saw the transition because
the GPS handler already consumed it by updating the cache. This caused
merged trips when the MQTT GPS burst arrived after 2+ min of parking
(True->False caught by GPS handler, watchdog saw False==False).

Now both paths trigger trip start/end, and the watchdog remains as
fallback for GPS-stale transitions between data updates.

The GPS handler updated _last_derived_is_moving on state changes but
did not trigger _end_driving_session or _anchor_driving_session. The
watchdog (every 30s) had that logic but never saw the transition because
the GPS handler already consumed it by updating the cache. This caused
merged trips when the MQTT GPS burst arrived after 2+ min of parking
(True->False caught by GPS handler, watchdog saw False==False).

Now both paths trigger trip start/end, and the watchdog remains as
fallback for GPS-stale transitions between data updates.
avgAuxPower is unreliable (static value, only via API polls, never
during drives), so aux subtraction always contributed zero energy.
Simplifies learning and prediction to pure distance-based consumption.
Charging path aux tracking in soc_prediction.py is unaffected.
@renaudallard

Copy link
Copy Markdown
Contributor Author

Last commit remove the useless auxpower which never seems to be right.

Extract SOC wiring, device info, and housekeeping into separate files.
Coordinator keeps thin delegates to preserve its public API.

New files:
- soc_wiring.py: SOC/charging/driving prediction wiring (~675 lines)
- device_info.py: metadata building, BEV detection, state restoration (~214 lines)
- coordinator_housekeeping.py: diagnostics, cleanup, connection events (~269 lines)
Add module table showing the codebase structure after the coordinator
refactoring. Fix "Extrapolated SOC" references to "Predicted SOC".
@kvanbiesen kvanbiesen merged commit dca3e56 into kvanbiesen:main Feb 15, 2026
6 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.

2 participants