Skip to content

fix: use single-shot low battery notifications#5550

Merged
jamesarich merged 1 commit into
mainfrom
jamesarich/fix-less-aggressive-battery-notification
May 20, 2026
Merged

fix: use single-shot low battery notifications#5550
jamesarich merged 1 commit into
mainfrom
jamesarich/fix-less-aggressive-battery-notification

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

Motivation

The previous low battery notification system was overly aggressive -- remote favorite nodes triggered a notification on every telemetry update (gated only by a 25-minute cooldown), and a "critical" threshold bypassed the cooldown entirely. This led to notification fatigue, especially for users with multiple favorite nodes in the field.

Approach

Replaced the cooldown-timer model with a single-shot, state-change approach (similar to Home Assistant, Tile, and AirTag):

  • One notification per low-battery episode: When a node's battery drops to or below 20%, a single notification fires.
  • No repeats: The node is tracked in a notifiedNodes set. No further notifications fire while it remains below threshold.
  • Automatic reset: When the node's battery recovers above 20%, the flag clears and the notification is dismissed -- allowing a fresh alert if it drops again later.

This eliminates all cooldown timers, divisor-based thresholds, and the critical-bypass logic, resulting in a much simpler and less intrusive notification experience.

Notes

  • The shouldBatteryNotificationShow function signature retains its parameters for interface compatibility but the logic is now trivial (check-and-add to a set).
  • Existing tests continue to pass; the test suite validates telemetry processing rather than notification frequency.

@github-actions github-actions Bot added bugfix PR tag enhancement New feature or request labels May 20, 2026
Adopt a state-change model for battery notifications instead of the
previous cooldown-based approach. Each node now receives exactly one
notification when its battery drops to or below 20%. The notification
flag is cleared when the battery recovers above 20%, allowing a new
notification on the next low-battery episode.

This matches the UX pattern used by Home Assistant, Tile, and AirTag
where users are informed once per low-battery episode without repeated
alerts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesarich jamesarich force-pushed the jamesarich/fix-less-aggressive-battery-notification branch from aaed407 to 6de8c35 Compare May 20, 2026 21:34
@github-actions

Copy link
Copy Markdown
Contributor

🖼️ Preview staleness check — advisory

This PR modifies UI composables but does not update any *Previews.kt files.

Previews power screenshot tests and in-app docs screenshots. Keeping them current ensures visual regression coverage stays accurate.

Changed UI files:

feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/component/SecurityConfigScreen.kt

What to check:

Pattern Preview file convention
feature/{name}/…/ui/ or component/ feature/{name}/…/*Previews.kt
core/ui/…/ core/ui/…/ (previews colocated)

Adding previews checklist:

  1. Create or update a *Previews.kt file in the same module with @PreviewLightDark
  2. Add @Suppress("PreviewPublic") if the preview is consumed by screenshot-tests
  3. Add corresponding @PreviewTest function in screenshot-tests/src/screenshotTest/
  4. Run ./gradlew :screenshot-tests:updateDebugScreenshotTest to generate reference images

If this PR does not require preview updates (e.g., logic-only change, non-visual refactor), add the skip-preview-check label to dismiss.

@github-actions

Copy link
Copy Markdown
Contributor

📄 Docs staleness check — advisory

This PR modifies user-facing UI source files but does not update any page under docs/en/user/ or docs/en/developer/.

⚠️ Doc changes propagate to 3 consumers: in-app docs browser, Jekyll site (GitHub Pages), and meshtastic.org (Docusaurus sync). Updating a page in docs/en/ automatically flows to all three.

Changed source files:

feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/component/SecurityConfigScreen.kt

What to check:

Changed area Likely doc page
feature/messaging/ docs/en/user/messages-and-channels.md
feature/node/ docs/en/user/nodes.md or docs/en/user/node-metrics.md
feature/map/ docs/en/user/map-and-waypoints.md
feature/connections/ docs/en/user/connections.md
feature/settings/ docs/en/user/settings-radio-user.md or docs/en/user/settings-module-admin.md
feature/firmware/ docs/en/user/firmware.md
feature/intro/ docs/en/user/onboarding.md
feature/discovery/ docs/en/user/discovery.md
feature/docs/ Internal docs infrastructure
core/ui/ docs/en/developer/codebase.md or component-specific user pages

New page checklist (if adding a new doc page):

  1. Create the .md file in docs/en/user/ or docs/en/developer/ with last_updated frontmatter
  2. Register in DocBundleLoader.kt with string resources (in-app browser)
  3. Jekyll and Docusaurus sync pick up new pages automatically — no config change needed

If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the skip-docs-check label to dismiss this check.

Cross-platform note: This check is advisory while doc coverage matures. Both Android and Apple repos use the same skip-docs-check label and advisory severity. See meshtastic/design standards for shared conventions.

@jamesarich jamesarich added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit 4c09377 May 20, 2026
16 checks passed
@jamesarich jamesarich deleted the jamesarich/fix-less-aggressive-battery-notification branch May 20, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant