Skip to content

Infer charging from a rising level on Bluetooth devices - #15

Merged
PyFlat-JR merged 1 commit into
feature/name-in-ringfrom
feature/inferred-charging
Oct 8, 2026
Merged

PyFlat-JR merged 1 commit into
feature/name-in-ringfrom
feature/inferred-charging

Conversation

@PyFlat-JR

@PyFlat-JR PyFlat-JR commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Shows Bluetooth devices as charging when their level keeps rising.

  • Bluetooth only reports a level, never whether a device charges, so BluetoothBatterySource always reported Discharging. It now marks that state as a guess (BatteryReading.StatusIsAssumed); an Unknown state counts the same.
  • ChargingInference runs in the poll loop before the registry, so the widgets, the charging and status variables, the trend and the charging started/stopped events all see the same state.
  • Starts once the level is at least 2 points above its lowest in the last 15 minutes. A device that reports in 10 % steps passes on its first step; 1 % jitter doesn't.
  • Ends on any drop below the peak, or after 30 minutes without a rise, so a device left at 100 % or taken off the charger doesn't stay charging. The history then restarts so the old low can't re-trigger it.
  • A state the source reported itself is never replaced.

Checklist

  • I have read AGENTS.md and CONTRIBUTING.md.
  • dotnet build and dotnet test pass locally (0 warnings, 265 tests).
  • I updated README.md / AGENTS.md if this changes what they describe.
  • If this touches a device backend: I tested it against the real hardware (see below).

Device/hardware tested against (if applicable)

The rules are covered by unit tests with a fake clock.

@PyFlat-JR
PyFlat-JR added this pull request to stack #18 October 8, 2026 07:25
@PyFlat-JR
PyFlat-JR merged commit 8c51915 into main Oct 8, 2026
3 checks passed
@PyFlat-JR
PyFlat-JR deleted the feature/inferred-charging branch October 8, 2026 07:29
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.

1 participant