Skip to content

Add Trio smoothed BG display option#648

Open
aug0211 wants to merge 5 commits into
loopandlearn:devfrom
aug0211:auggie-smoothing
Open

Add Trio smoothed BG display option#648
aug0211 wants to merge 5 commits into
loopandlearn:devfrom
aug0211:auggie-smoothing

Conversation

@aug0211

@aug0211 aug0211 commented May 9, 2026

Copy link
Copy Markdown
Contributor
  • 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.
@aug0211 aug0211 force-pushed the auggie-smoothing branch from e01f7f3 to 4b91b56 Compare May 9, 2026 04:08
aug0211 added 3 commits May 9, 2026 08:38
- 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
@dnzxy

dnzxy commented May 9, 2026

Copy link
Copy Markdown
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants