Add Trio smoothed BG display option#648
Open
aug0211 wants to merge 5 commits intoloopandlearn:devfrom
Open
Conversation
Contributor
aug0211
commented
May 9, 2026
- Adds Display Smoothed BG toggle in Settings → Advanced (off by default).
- Pulls smoothed values from Nightscout devicestatus openaps.enacted.bg / openaps.suggested.bg and stores an in-memory history bounded by the graph's day range.
- Renders smoothed values as a light-grey line on the main BG chart; CGM dots stay colorful, but the dot-connecting line is hidden while smoothing is on. Display Dots / Display Lines toggles are disabled in Graph Settings during this mode.
- Chart-tap popup shows the smoothed value (✨ … ✨) above the raw CGM value when a match is available within tolerance of the dot's timestamp.
- All work (fetches, parsing, polling) is gated on the toggle so users who don't enable it incur no extra overhead.
- Add the option for users to display the smoothed value in the information display table as well.
- Adds Display Smoothed BG toggle in Settings → Advanced (off by default). - Pulls smoothed values from Nightscout devicestatus openaps.enacted.bg / openaps.suggested.bg and stores an in-memory history bounded by the graph's day range. - Renders smoothed values as a light-grey line on the main BG chart; CGM dots stay colorful, but the dot-connecting line is hidden while smoothing is on. Display Dots / Display Lines toggles are disabled in Graph Settings during this mode. - Chart-tap popup shows the smoothed value (✨ … ✨) above the raw CGM value when a match is available within tolerance of the dot's timestamp. - All work (fetches, parsing, polling) is gated on the toggle so users who don't enable it incur no extra overhead. - Add the option for users to display the smoothed value in the information display table as well.
- When the latest Nightscout devicestatus record is "thin" (e.g. SMB-only notifications or partial loop runs that Trio sometimes writes between full-state runs), its enactedOrSuggested block lacks timestamp / bg / TDD, leaving the Updated, TDD, and Smoothed BG info-table rows empty - Add .smoothedBg to the per-update clear list in updateDeviceStatusDisplay so it's blanked alongside Updated and TDD on every refresh: no stale value persists past a sparse fetch - Detect a sparse record by snapshotting Observable.shared.enactedOrSuggested.value before processing and comparing after; the OpenAPS parser only updates that Observable when the timestamp parses, so an unchanged value signals a sparse record. - Extend the devicestatus fast-poll override so it fires on sparse records too. Same backoff as the smoothed-line retry: 3s while the latest BG is under 60s old, 15s out to 5 minutes, then fall back to the normal cadence. No count > 1 fetch, no historical fallback, just keep polling for the next full record.
- The Smoothed BG feature added a chart dataset that contributes ~280 entries per downloadDays day, pushing the chart's total data.entryCount from ~600 to ~880 with smoothing on (1-day default). - DGCharts gates value-label rendering on data.entryCount < maxVisibleCount × scaleX. With the library default of 100, the 3h zoom (scaleX = 8, cap 800) no longer cleared the new total, so bolus / carb / SMB value labels stopped appearing at 3h. - Set BGChart.maxVisibleCount = 150 so the threshold accommodates the extra entries while keeping ≥6h zooms hiding values, matching the prior behavior in both smoothing-on and smoothing-off states.
- Fix a cold-launch race condition where the sparse-record fast-poll would silently skip
Collaborator
|
Good idea to bring this in for LF x Trio. |
- Bug: Updated, TDD, and Smoothed BG rows showed blank or stale values. - Cause: parser picked just one of openaps.suggested / openaps.enacted (preferred suggested via ??), but Trio splits each loop's data across both blocks. suggested has fresh bg / IOB / COB / ISF / CR but no timestamp or TDD; enacted has timestamp and TDD but can linger at a previous loop's values. - Fix: merge both blocks with suggested winning on conflicts (latest loop's values), fall back to the record's outer created_at for the Updated timestamp, and switch to NightscoutUtils.parseDate so trailing Z / fractional seconds parse cleanly.
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.