Bluetooth-Devices / bthome-ble

Parser for BTHome BLE devices
https://bthome.io/
MIT License
71 stars 15 forks source link

Parser not working properly with multiple elements in service_data #19

Closed gallmerci closed 1 year ago

gallmerci commented 1 year ago

Describe the bug I am using the BTHome integration from the Home Assinstant which uses bthome-ble for the bluetooth BLE discovery. I want to connect a Xiami temperature sensor to my HA system. I flashed the temperatur sensor with the custom image (flasher) and set the config to BTHome. The sensor is correctly discovered in HA but when trying to connect to the device, it does not show all available sensor (temperatur, humidity, battery, ...) but only signal strength. When debugging I noticed that the AdvertisementData contains multiple elements in the service_data dictionary.

Here an example AdvertisementData from the HA logs:

AdvertisementData(local_name='ATC_NO3', service_data={'0000181a-0000-1000-8000-00805f9b34fb': b'\xc4$\x818\xc1\xa4V\x08\x83\x18\xbf\x0bYB\x05', '0000fe95-0000-1000-8000-00805f9b34fb': b'0X[\x05\x01\xc4$\x818\xc1\xa4(\x01\x00', '0000181c-0000-1000-8000-00805f9b34fb': b'\x02\x00\xb4\x02\x10\x00\x03\x0c\xbe\x0b'})

The parser.py here only checks for single element key list but checks against the entire list of keys in service_data. When I changed this line to also pass the uuid and only checks against this single uuid, everything worked fine.

To Reproduce I hope I put everything in the bug description.

Additional context NA

Ernst79 commented 1 year ago

Should be fixed in V2 release, after #21 is merged. V2 will be release very soon.

gallmerci commented 1 year ago

Thanks for the quick fix!