Skip to content

feat: show other providers' battery devices in the widgets - #27

Merged
PyFlat-JR merged 1 commit into
mainfrom
feature/external-battery-devices
Oct 15, 2026
Merged

PyFlat-JR merged 1 commit into
mainfrom
feature/external-battery-devices

Conversation

@PyFlat-JR

Copy link
Copy Markdown
Member

What does this PR do?

Lets both widgets show devices that other providers publish to Macro Deck's battery catalog (SDK beta.17, IIntegrationContext.Batteries), such as the phones from the built-in ADB integration, next to this plugin's own devices.

  • Picker: the widget's device list shows this plugin's devices first, then every catalog device from another provider, labelled device - provider. This plugin's own catalog entries are filtered out by the id it published.
  • Rows: a picked external device is drawn like our own devices, with level, charging state, time to full and our icon for its kind. A disconnected device shows as stale.
  • Storage: a widget stores an external device by its catalog id (provider:id). The colon keeps those ids from ever clashing with our own device ids.
  • Existing widgets: an empty selection still means this plugin's devices only, so existing widgets don't gain rows.
  • Widgets only: external devices get no battery_<id>_* variables, no events and no trend.
  • Row keys: a widget element key can't contain a colon, so external rows are keyed by a short SHA-256 hash of the catalog id (ExternalBatteryDevices.RowKey). A test opens a real widget session to cover this.
  • Live updates: the host drops a context Changed handler on every re-initialization, and widget sessions stay open across that. So the integration re-subscribes in InitializeAsync and raises its own BatteryCatalogChanged, which the sessions listen to.
  • Mapping back: headphones become our headset icon, laptop becomes the system icon, and watch and unknown kinds become other. NotCharging reads as Full at 100 % and Unknown below, matching our macOS and Linux sources.
  • Docs: README, AGENTS.md and the sourceIds description in the widget data schema are updated. There is one new string, Widgets.Config.Devices.External.

Checklist

  • I have read AGENTS.md and CONTRIBUTING.md.
  • dotnet build and dotnet test pass locally (0 warnings, 316 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)

Not a device backend.

@PyFlat-JR PyFlat-JR self-assigned this Oct 15, 2026
@PyFlat-JR
PyFlat-JR merged commit 1b6e615 into main Oct 15, 2026
3 checks passed
@PyFlat-JR
PyFlat-JR deleted the feature/external-battery-devices branch October 15, 2026 21:59
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