Closed rrooggiieerr closed 2 weeks ago
What is the macOS version?
Sonoma 14.3
I don't know what else could be done here besides raise an error with a more useful message. We can't allow None
otherwise there would be no way to tell devices apart. This is using an undocumented feature of macOS which is subject to change or be removed without notice. Bleak doesn't use this by default, but Home Assistant is opting in to using the risky feature. It would probably be better if Home Assistant didn't do this to begin with.
I understand the undocumented nature of the implementation. My thought would be to check on None
value to prevent the AttributeError
and just ignore the device if None
. Something like:
address_bytes: bytes = (
self._manager.central_manager.retrieveAddressForPeripheral_(p)
)
if address_bytes is None:
logger.warning("NoneType device address")
return
address = address_bytes.hex(":").upper()
Is it only some devices but not all devices that return None
?
Seems to be only incidental. And I don't know which device. I'm receiving successful updates from my BLE devices
If that is the case, then I would take a pull request with the change you suggest. It probably just needs to be logger.debug
though and maybe we could include the peripheral ID in the message so we can see what device it is. Maybe it just takes a while to resolve the Bluetooth address and subsequent calls return non-None.
logger.debug("Could not get Bluetooth address for %s. Ignoring this device.", p.identifier().UUIDString())
Ok, fair enough. But I don't have a bleak development environment setup, and don't like to create an untested pull request, even though I'm quite confident it would resolve the matter. Also it's quite difficult to test since the sporadic nature of the None type address. But if you're fine with an untested pull request I'll go ahead.
Can you test by editing your Home Assistant install?
I would not know how to reproduce the issue, it happened only once in the last 8 hours
bluetoothctl -v
) in case of Linux:Description
The following exception was logged on my local Home Assistance instance:
address_bytes is not checked on being None
What I Did
Just running Home Assistant
Logs
See above