device: also show bolt pairing errors

This commit is contained in:
Peter F. Patel-Schneider 2025-12-10 11:15:08 -05:00
parent 74364cf0ea
commit 5509a21844
3 changed files with 7 additions and 3 deletions

View File

@ -165,6 +165,10 @@ class BoltPairingError(IntEnum):
DEVICE_TIMEOUT = 0x01
FAILED = 0x02
@property
def label(self) -> str:
return self.name.lower().replace("_", " ")
class Registers(IntEnum):
"""Known HID registers.

View File

@ -454,7 +454,7 @@ def handle_discovery_status(receiver: Receiver, notification: HIDPPNotification)
receiver.pairing.device_passkey = None
discover_error = ord(notification.data[:1])
if discover_error:
receiver.pairing.error = discover_string = hidpp10_constants.BoltPairingError(discover_error).name
receiver.pairing.error = discover_string = hidpp10_constants.BoltPairingError(discover_error).label
logger.warning("bolt discovering error %d: %s", discover_error, discover_string)
receiver.changed(reason=reason)
return True
@ -496,7 +496,7 @@ def handle_pairing_status(receiver: Receiver, notification: HIDPPNotification) -
elif notification.address == 0x02 and not pair_error:
receiver.pairing.new_device = receiver.register_new_device(notification.data[7])
if pair_error:
receiver.pairing.error = error_string = hidpp10_constants.BoltPairingError(pair_error).name
receiver.pairing.error = error_string = hidpp10_constants.BoltPairingError(pair_error).label
receiver.pairing.new_device = None
logger.warning("pairing error %d: %s", pair_error, error_string)
receiver.changed(reason=reason)

View File

@ -58,7 +58,7 @@ def test_process_receiver_notification(sub_id, notification_data, expected_error
result = notifications.process_receiver_notification(receiver, notification)
assert result
assert receiver.pairing.error == (None if expected_error is None else expected_error.name)
assert receiver.pairing.error == (None if expected_error is None else expected_error.label)
assert receiver.pairing.new_device is expected_new_device