fix: recover last trip distance when the board wipes it on remote power-cycle - #10
Merged
Merged
Conversation
…er-cycle The board's DP5 (mileage_once) is wiped to 0 when the remote is power-cycled (e.g. turning it off then back on to sync at home), which blanked a just-completed ride on the dashboard. Recovery now lives in the coordinator, the only place that sees both the previous and current read. When DP5 reads 0 the effective last-trip distance is derived from the cumulative odometer (DP12) delta if the odometer advanced between reads, and otherwise the last known trip is preserved instead of being overwritten with 0 (the flat-odometer reconnect/sync case). A nonzero DP5 is always trusted as-is. Also bump manifest to 0.3.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The board reports per-trip distance via DP5
mileage_once, but the board wipes DP5 to 0 when the remote is power-cycled — e.g. turning it off then back on to "sync" once you're home in range. That blanked a just-completed ride's distance on the dashboard (shows0.00 mi).Fix
Trip-distance recovery now lives in the coordinator, the only place with access to both the previous and current read. A new
EboardSnapshot.trip_distance_km10carries an effective last-trip value computed each read:The
trip_distancesensor now reads the recovered value instead of DP5 directly.Notes / known limits
ridetime_once) is not recoverable the same way: there is no cumulative ride-time counter to derive a delta from, and the board reports DP6 inconsistently. Left as-is.Testing
ruff check custom_components— cleanpytest -q— 28 passed (pure suite, no hardware/HA)Bumps manifest to 0.3.1.