core icon indicating copy to clipboard operation
core copied to clipboard

Mi Flora advertisements not handed to xiaomi_ble parser

Open mundschenk-at opened this issue 3 years ago • 15 comments

The problem

I've several Mi Flora sensors currently running with the custom Passive Bluetooth Monitor integration, but I'd like to switch to the new core integration. I've both internal Bluetooth in the HA Yellow and a Bluetooth Proxy set up. I have disabled the old custom component and I've enabled debug logs for homeassistant.components.bluetooth and xiaomi_ble.

From the logs, I see that the Bluetooth Manager sees the advertisements and recognizes them as belonging to xiaomi_ble. However, it does not look like the xiaomi_ble.parser is ever called for these. There are other non-Xiaomi advertisments that strangely are handled by xiaomi_ble.parser.

What version of Home Assistant Core has the issue?

core-2022.10.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Xiaomi BLE

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_ble/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-10-22 18:49:31.727 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] <MAC addresses> AdvertisementData(local_name='Flower care', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'q \x98\x00\x9b\x1b\x17n\x8d|\xc4\r\t\x10\x02\xe0\x00'}, service_uuids=['0000fe95-0000-1000-8000-00805f9b34fb']) connectable: True match: {'xiaomi_ble'} rssi: -83
...
2022-10-22 18:51:04.166 DEBUG (MainThread) [xiaomi_ble.parser] Parsing Xiaomi BLE advertisement data: BluetoothServiceInfoBleak(name='Hue Light', address='<MAC address>', rssi=-75, manufacturer_data={}, service_data={'0000fe0f-0000-1000-8000-00805f9b34fb': b'e\x10$a\n'}, service_uuids=['0000fe0f-0000-1000-8000-00805f9b34fb'], source='<MAC address>', device=<MAC address>: Hue Light, advertisement=AdvertisementData(local_name='Hue Light', service_data={'0000fe0f-0000-1000-8000-00805f9b34fb': b'e\x10$a\n'}, service_uuids=['0000fe0f-0000-1000-8000-00805f9b34fb'], tx_power=10), connectable=True, time=610866.411322009)

Additional information

No response

mundschenk-at avatar Oct 22 '22 19:10 mundschenk-at

Hey there @jc2k, @ernst79, mind taking a look at this issue as it has been labeled with an integration (xiaomi_ble) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of xiaomi_ble can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant unassign xiaomi_ble Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


xiaomi_ble documentation xiaomi_ble source (message by IssueLinks)

home-assistant[bot] avatar Oct 22 '22 19:10 home-assistant[bot]

It's been working for me on 2022.10.1.

mdonoughe avatar Oct 23 '22 13:10 mdonoughe

@mundschenk-at Can you attach the diagnostic data?

I am very suspicious of how xiaomi_ble could be loaded for the Phillips Hue bulb, as checking this, xiaomi_ble should only be invoked if 0000fe95-0000-1000-8000-00805f9b34fb is present, and it isn't in the log snippet you provided. I'd need to see more log file to see what was doing on.

The Mi Flora in question - have you been able to add any of them? If not, are they visible if you go to "Add integration", "Xiaomi", "Xiaomi BLE" ?

(I also have 3 of different ages that are working fine here)

Jc2k avatar Oct 23 '22 14:10 Jc2k

@Jc2k Any way to make the diagnostic files available to you privately? Redacting the MAC addresses of all BT-enabled devices here is quite a task ;-)

I've got several Mi Flora (the small ones) and two VegTrug Grow Care Garden (the big ones). All worked fine with BLE Monitor, but none are visible when trying to add the integration manually. It almost looks as if the logic what gets handed to xiaomi_ble.parser is inverted somewhere. All my non-Xiaomi devices have corresponding logfile entries, and none of the Xiaomi do.

mundschenk-at avatar Oct 23 '22 16:10 mundschenk-at

My username on the HA discord is the same if you want to sent a private message there.

Jc2k avatar Oct 23 '22 16:10 Jc2k

Thx, I'll check it out (haven't used Discord a lot).

Anyway, I've searched the logs for the characteristic you mentioned and noticed that the debug message notably does not contain xiaomi_ble in recent log messages in the match set.

2022-10-23 18:44:09.603 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] <MAC addresses> AdvertisementData(local_name='Flower care', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'q \x98\x008\xfb\x13n\x8d|\xc4\r\x08\x10\x01\x0c'}, service_uuids=['0000fe95-0000-1000-8000-00805f9b34fb']) connectable: True match: set() rssi: -73
2022-10-23 18:44:09.636 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] <MAC addresses> AdvertisementData(local_name='Flower care', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'q \x98\x00Q\x0f\x15n\x8d|\xc4\r\x08\x10\x01\n'}, service_uuids=['0000fe95-0000-1000-8000-00805f9b34fb']) connectable: True match: set() rssi: -82
2022-10-23 18:44:09.935 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] <MAC addresses> AdvertisementData(local_name='Flower care', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'q \x98\x00\xa6\x1a\x17n\x8d|\xc4\r\x04\x10\x02\x98\x00'}, service_uuids=['0000fe95-0000-1000-8000-00805f9b34fb']) connectable: True match: set() rssi: -79
2022-10-23 18:44:16.862 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] <MAC addresses> AdvertisementData(local_name='Flower care', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'q \x98\x00\x88L\x16n\x8d|\xc4\r\x08\x10\x01\x02', '00009500-0000-1000-8000-00805f9b34fb': b'\xfeq \x98\x00\x93n\x8d|\xc4\r\t\x10\x02\x00\x00\xa8'}, service_uuids=['0000fe95-0000-1000-8000-00805f9b34fb']) connectable: True match: set() rssi: -82
2022-10-23 18:44:19.589 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] <MAC addresses> AdvertisementData(local_name='Flower care', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'q \x98\x009\xfb\x13n\x8d|\xc4\r\t\x10\x02\x00\x00'}, service_uuids=['0000fe95-0000-1000-8000-00805f9b34fb']) connectable: True match: set() rssi: -74

mundschenk-at avatar Oct 23 '22 16:10 mundschenk-at

I think it is only supposed to match once, as an optimisation. Otherwise it would create a discovery flow every advertisement and those pis everyone are using would set on fire under the load... but I'll check when I can get to my desk.

Jc2k avatar Oct 23 '22 16:10 Jc2k

(That's also the reason you sometimes don't get "discovery" but the device is in the list if you add it manually)

Jc2k avatar Oct 23 '22 16:10 Jc2k

I think it is only supposed to match once, as an optimisation. Otherwise it would create a discovery flow every advertisement and those pis everyone are using would set on fire under the load... but I'll check when I can get to my desk.

Ah!

mundschenk-at avatar Oct 23 '22 16:10 mundschenk-at

My username on the HA discord is the same if you want to sent a private message there.

I've sent you the diagnostic log.

mundschenk-at avatar Oct 23 '22 18:10 mundschenk-at

So to confirm, when you go to http://yourha:8123/config/integrations and click the "Add Integration" button, then select xiaomi, then select xiaomi ble, do you get an error that basically says "no devices found"?

Jc2k avatar Oct 23 '22 20:10 Jc2k

Yes, exactly.

mundschenk-at avatar Oct 23 '22 20:10 mundschenk-at

And theres definitely no ignored or disabled integrations in your setup?

Jc2k avatar Oct 23 '22 20:10 Jc2k

None. I've also deleted the BLE Monitor integration and removed the custom component from HACS entirely to prevent any conflict there (although I understand there should not have been one).

mundschenk-at avatar Oct 23 '22 20:10 mundschenk-at

I've now also rebooted the entire devices to make sure there are no issues with incorrect BT hardware initialization (but since the advertisements are received, that was unlikely).

mundschenk-at avatar Oct 24 '22 15:10 mundschenk-at

@Jc2k Anything I can do to help track this down?

mundschenk-at avatar Oct 26 '22 14:10 mundschenk-at

And theres definitely no ignored or disabled integrations in your setup?

Sorry, I feel like a complete idiot now. There were ignored integrations after all. I never even thought of those (because I had ignored them long ago when the new BT integration first came along and I had since removed the "base" BT integration).

mundschenk-at avatar Nov 03 '22 06:11 mundschenk-at