Skip to content

feat(gui): a ble_address schema field, so any BLE device can offer Scan - #136

Merged
gbradham merged 1 commit into
mainfrom
feat/ble-address-schema-field
Aug 21, 2026
Merged

feat(gui): a ble_address schema field, so any BLE device can offer Scan#136
gbradham merged 1 commit into
mainfrom
feat/ble-address-schema-field

Conversation

@gbradham

Copy link
Copy Markdown
Member

Second of three for making Maimu installable as a plugin. Follows #135 (node extension points); the Maimu move itself is next.

The gap

A device rendered through the generic schema form got a plain text box for its address. Only the built-ins have a Scan button, because hardware_panel special-cases them by name — which a plugin device by definition cannot be.

Pasting a BLE MAC by hand is the difference between a device a researcher can add and one they have to be walked through. Moving Maimu to a plugin without this would have been a straight downgrade.

What this adds

A "ble_address" field type in schema_form, usable from any device's SETTINGS_SCHEMA:

{"key": "address", "label": "Address / UUID", "type": "ble_address"}

It also moves the widget itself out of hardware_panel. The hand-built dialog rows and the schema-rendered form a plugin gets are now the same widget rather than two that drift apart. That is the third duplicated-implementation bug this week (#129 two file formats, #133 two hardware-population loops), so writing a second copy here would have been a poor joke.

Degradation is deliberate

Scanning is async and the form has no event loop of its own, so the caller passes a runner. Without one the field still renders and stays editable — only the button is dropped. An address can always be typed, and a form that refused to render because it could not scan would be worse than one that simply cannot scan.

Reading it back

All three ways an address arrives are handled: picked from a scan, where the address is item data behind an advertised-name label; typed by hand; or pasted as a whole scan label, where a trailing " (name)" is stripped.

Tests — 8 new

Scan offered when a runner is supplied; degrades to a typeable field without one; clicking Scan actually runs the coroutine; a typed address reads back; a scanned entry reads back its address, not its label; a pasted label is stripped; a saved address is shown; an empty field reads back empty.

Verification

PYTHONPATH=src QT_QPA_PLATFORM=offscreen pytest tests/3680 passed, 4 skipped, ruff and black clean.

A device rendered through the generic schema form got a plain text box for
its address. Only the built-ins had a Scan button, because the hardware panel
special-cases them by name -- which a plugin device cannot be. Pasting a MAC
by hand is the difference between a device a researcher can add and one they
have to be walked through.

schema_form gains a "ble_address" field type. It also gains the widget itself,
moved out of hardware_panel: the hand-built dialog rows and the schema-rendered
form are now the same widget rather than two that drift. That is the third
duplicated-implementation bug this week, so building a second copy here would
have been a poor joke.

Scanning is asynchronous and the form has no loop of its own, so the caller
passes a runner. Without one the field still renders and stays editable and
only the button is dropped -- an address can always be typed, and a form that
refused to render because it could not scan would be worse than one that
cannot scan.

Reading the field back handles all three ways an address arrives: picked from
a scan, where the address is the item data behind an advertised-name label;
typed by hand; or pasted as a whole scan label, where the trailing " (name)"
is stripped.
@gbradham
gbradham merged commit 995e7f3 into main Aug 21, 2026
4 checks passed
@gbradham
gbradham deleted the feat/ble-address-schema-field branch August 21, 2026 03:19
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