home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.31k stars 30.62k forks source link

Xiaomi BLE: Thermometer XMWSDJ04MMC frequently unavailable #80750

Closed Halytskyi closed 1 year ago

Halytskyi commented 2 years ago

The problem

I was able to add "XMWSDJ04MMC" to HA. It asked me provide bind-key and I even start see entities with temp/ hum/ bat and signal), but on device bluetooth icon is hidden (from my understanding, after connection, it should be shown and not blinking?). But the main issue that it being frequently unavailable.

Screen Shot 2022-10-21 at 12 04 22 PM

I found similar issue for LYWSD03MMC (#78195), but I don't use "BT Home" or/and customized firmware, therefore, it can be different issue.

P.S. I have 3 x "XMWSDJ04MMC" and all of them have the same issue. Device hardware version: va1.0 Device firmware version: 2.0.1_0032

What version of Home Assistant Core has the issue?

2022.10.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

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?

No response

Additional information

No response

home-assistant[bot] commented 2 years ago

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)

Jc2k commented 2 years ago

If devices don't broadcast very often then HA thinks they are out of range or out of battery and marks them as unavailable. This can create the sort of pattern that you see. It's possible the broadcast interval on your firmware version is slower than mine so I don't see it. This will be fixed in 2022.11.x (we auto calibrate for each devices particular broadcast interval). If you have a way to test it out in beta or something that would be great.

We don't actually connect to these devices. everything we do is completely passive. So i won't expect it to show any signs that we had connected to it. Mine don't have a blinking indicator.

Halytskyi commented 2 years ago

ok, great, I'll wait for 2022.11 version, thanks :)

Halytskyi commented 2 years ago

Upgraded to 2022.11.0 but issue still exists :(

willemstoker commented 1 year ago

Exact same issue here. Running 2022.11.3

I think the broadcast interval of the sensor depends on the tempareture change. So if the temparture doesn't change it won't send a new value for a while. Is it possible to see and manually set the used interval for the sensor when it will be unavailable?

Jc2k commented 1 year ago

So working fine for me here:

Screenshot 2022-11-17 at 11 41 12

Mine are all from different batches (there are subtle hardware revisions between them), and all running stock firmware. I've not customised it in any way.

The interval for XMWSDJ04MMC (at least for the 4 I have) is slow but fixed, and the temperature changing does not increase the rate.

The interval used by HA for marking devices as unavailable is automatically calibrated since 2022.11.0. You can see it by downloading a "Diagnostics" report for the bluetooth integration. If you search in that file for "interval" you will see the calibration for each Mac address.

Jc2k commented 1 year ago

Looking at the original graph, I noticed how regular the gaps were. I wonder if you both have BLE monitor running and they are fighting for control of the bluetooth dongle. That has been reported before, and disabling it has fixed things. If you need both, apparently running blemonitor in active scanning mode can help.

I guess another thing is your dongle could be crashing frequently and the HA auto recover mechanism kicks in like clock work. Realtek adapters in particular were very crashy and would stop working entirely before the auto recover mechanism was added.

willemstoker commented 1 year ago

Jc2k, thanks for your response. The interval shows "32.95710667595267". It means when there is 32 sec no data the sensor shows unavailable?

I'm not running any BLE monitors. I'm running HA om a RPI 3 with bluetooth build in. May be the sensor is out of range for a lot of readings so it misses a lot. Since the temperature is not changing really fase it's not a problem for me, but I don't like the the sensor showing "unavailable" after 32 sec.. How long will it take to calibrate? I'm having this issue since I've updated to 2022.11

Jc2k commented 1 year ago

If it says 32, it means we are seeing data from your device every 32 seconds, that's not how long we'll wait till unavailable. I don't know what we do wait off the top of my head, but there is some headroom added so it's longer than that. To be clear, that doesn't mean we get a temp reading that often, this device does broadcast that often but it only updates the temp every 10 minutes.

AIUI the calibration is ongoing, so at the point in time you looked the longest interval it had seen was 32 seconds. But if it dropped down to a cadence of 60s it should notice and adjust.

We are probably going to need to turn on debug logs to get a full sense of what is happening. They are going to be very verbose. Will send some instructions when I'm near a computer, not sure I'll make it tonight tho.

Halytskyi commented 1 year ago

As Bluetooth module I use "Intel AX210NGW" which finding all my bluetooth devices (before I tried "EDUP LOVE EP-B3536 (RTL8761BU)" which in "known working adapters" list, but it can't find even half my devices). How I can check if this is not bluetooth adapter issue? I don't see any strange/related messages in syslog/dmesg/ha logs... But one thing I noticed that almost all my bluetooth sensors becoming "unavailable" at the same time at once (but not always), which seems can be adapter or software issue. And I also don't run "BLE monitor", I use only integrated HA bluetooth implementation.

In "bluetoothctl" I see a lot messages like:

[CHG] Device 71:52:24:0D:FE:08 RSSI: -74
[CHG] Device 56:9E:DA:9E:1E:A1 RSSI: -76
[CHG] Device 71:52:24:0D:FE:08 RSSI: -74

Seems this is some verbose info about signal? Is bluetooth adapter always scanning devices (sorry, I'm new in bluetooth... edited: as I see this is from HA bluetooth integration, once I disable it - no messages anymore + in that case I can confirm that no other soft use it)? And between these messages I see messages that my devices adding and removing:

[NEW] Device 8C:F6:31:01:EB:05 XMWSDJ04MMC
...
[DEL] Device 8C:F6:31:01:EB:05 XMWSDJ04MMC

In debug logs (for bluetooth) I see:

Nov 19 13:01:56 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -84 flags 0x0004 eir_len 26
Nov 19 13:01:56 worker01 bluetoothd[84457]: src/device.c:device_create() dst 8C:F6:31:01:EB:05
Nov 19 13:01:56 worker01 bluetoothd[84457]: src/device.c:device_new() address 8C:F6:31:01:EB:05
Nov 19 13:01:57 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -83 flags 0x0004 eir_len 26

Nov 19 13:04:56 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -87 flags 0x0004 eir_len 31
Nov 19 13:04:56 worker01 bluetoothd[84457]: src/device.c:device_create() dst 8C:F6:31:01:EB:05
Nov 19 13:04:56 worker01 bluetoothd[84457]: src/device.c:device_new() address 8C:F6:31:01:EB:05
Nov 19 13:04:56 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -84 flags 0x0004 eir_len 26
Nov 19 13:04:56 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -85 flags 0x0004 eir_len 26
Nov 19 13:04:56 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -85 flags 0x0004 eir_len 26
Nov 19 13:04:57 worker01 bluetoothd[84457]: src/adapter.c:device_found_callback() hci0 addr 8C:F6:31:01:EB:05, rssi -85 flags 0x0004 eir_len 26

Is this can be the issue?

bstempien commented 1 year ago

Hello, I have not been following this for awhile. I did pull the Diagnostic report for the bluetooth adapter, and I only see 3 out of the 10 Moisture Sensors I have in the advertisement_tracker -> intervals section. When I check on those that do show up, they do show long intervals where they didn't report Unavailable. But I do see where earlier in the day they were doing the standard cycle of becoming unavailable and then the broadcast comes thru and it becomes available again within a minute or so. I am currently running 2022.11.4 on an x86_64 HAOS 9.3

Charisketi commented 1 year ago

I also have the same problem with Xiaomi BLE XMWSDJ04MMC. Every time the device is unavailable, downloading a "Diagnostics" report for the bluetooth i get:

      "advertisement_tracker": {
        "intervals": {
          ..........
        },
        "sources": {
          ............
        },
        "timings": {}
      }
    },

Every timethe device is available, downloading a "Diagnostics" report for the bluetooth i get:

      "advertisement_tracker": {
        "intervals": {
          ........
        },
        "sources": {
         ...........
        },
        "timings": {
          "11:1C:.....": [    -----> DEVICE MAC ADDRESS
            90927.235480588
          ]
        }
      }
    },
Charisketi commented 1 year ago

This is my debug log:

2022-12-14 21:02:42.987 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 1: {'ssdp', 'cloud', 'api', 'dhcp', 'webhook', 'usb', 'hassio', 'http', 'websocket_api', 'bluetooth', 'network', 'zeroconf'}
2022-12-14 21:02:43.087 INFO (MainThread) [homeassistant.setup] Setting up bluetooth
2022-12-14 21:02:43.429 INFO (MainThread) [homeassistant.setup] Setup of domain bluetooth took 0.3 seconds
2022-12-14 21:02:43.434 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] Initializing bluetooth scanner with {'detection_callback': <bound method HaScanner._async_detection_callback of <homeassistant.components.bluetooth.scanner.HaScanner object at 0x7f21157fdde0>>, 'scanning_mode': 'active', 'adapter': 'hci0'}
2022-12-14 21:02:43.435 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Starting bluetooth discovery attempt: (1/3)
2022-12-14 21:02:43.510 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] Registering scanner hci0 (--BT MAC ADDRESS--)
2022-12-14 21:02:43.937 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --OTHER MAC ADDRESS-- AdvertisementData(manufacturer_data={301: b'\x02\x00\x01\x10F\xdd\x8aB-\xc1L\x00\x9bo)S\x03\xf6\x8a\xad\x14Bb"\x95;'}, rssi=-94) match: set()
2022-12-14 21:02:44.098 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --OTHER MAC ADDRESS-- AdvertisementData(manufacturer_data={224: b'\x01\x15\xca\x98\x85m'}, service_data={'0000fe9f-0000-1000-8000-00805f9b34fb': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}, service_uuids=['0000fe9f-0000-1000-8000-00805f9b34fb'], rssi=-92) match: set()
2022-12-14 21:02:44.483 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --OTHER MAC ADDRESS-- AdvertisementData(manufacturer_data={76: b'\x02\x15Pv\\\xb7\xd9\xeaN!\x99\xa4\xfa\x87\x96\x13\xa4\x92\xef:\x860\xce'}, rssi=-96) match: {'ibeacon'}
2022-12-14 21:02:46.355 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2022-12-14 21:02:46.957 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --OTHER MAC ADDRESS-- AdvertisementData(manufacturer_data={224: b'\x01\x14\xca\x98$Z'}, service_data={'0000fe9f-0000-1000-8000-00805f9b34fb': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}, service_uuids=['0000fe9f-0000-1000-8000-00805f9b34fb'], rssi=-84) match: set()
2022-12-14 21:02:52.917 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:03:13.512 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 5.957200680000824
2022-12-14 21:03:43.513 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 4.710158668996883
2022-12-14 21:03:46.361 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2022-12-14 21:03:51.368 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:04:13.514 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 3.260109819995705
2022-12-14 21:04:43.514 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 0.7500252640020335
2022-12-14 21:04:56.359 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:04:57.046 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --DEVICE MAC ADDRESS-- AdvertisementData(local_name='XMWSDJ04MMC', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'\x10Y\x03\x12Q\xf0"\xa7\xf14\x1c'}, rssi=-92) match: {'xiaomi_ble'}
2022-12-14 21:05:13.516 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 9.642324796994217
2022-12-14 21:05:43.517 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 7.087238724008785
2022-12-14 21:05:56.365 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:06:13.517 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 3.501117929001339
2022-12-14 21:06:23.855 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2022-12-14 21:06:28.863 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:06:43.518 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 2.3120778769953176
2022-12-14 21:06:57.147 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --DEVICE MAC ADDRESS-- AdvertisementData(local_name='XMWSDJ04MMC', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'HY\x03\x12St\xb6\xa4\xb5\xc1\x12m\x00\x00\x00R\x98 /'}, rssi=-96) match: set()
2022-12-14 21:07:13.520 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 1.043035131006036
2022-12-14 21:07:23.859 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2022-12-14 21:07:28.867 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:07:43.520 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 8.469285258994205
2022-12-14 21:08:13.521 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 3.4251153619989054
2022-12-14 21:08:33.864 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:08:43.521 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 2.504084337997483
2022-12-14 21:08:47.433 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2022-12-14 21:08:52.441 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:09:13.522 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 1.716057796991663
2022-12-14 21:09:33.862 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:09:43.523 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 0.587019769998733
2022-12-14 21:09:44.017 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --OTHER MAC ADDRESS-- AdvertisementData(manufacturer_data={76: b'\x02\x15Pv\\\xb7\xd9\xeaN!\x99\xa4\xfa\x87\x96\x13\xa4\x92\xef:\x860\xce'}, rssi=-94) match: {'ibeacon'}
2022-12-14 21:09:55.568 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --OTHER MAC ADDRESS-- AdvertisementData(manufacturer_data={301: b'\x02\x00\x01\x10F\xdd\x8aB-\xc1L\x00\x9bo)S\x03\xf6\x8a\xad\x14Bb"\x95;'}, rssi=-98) match: set()
2022-12-14 21:09:57.040 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --DEVICE MAC ADDRESS-- AdvertisementData(local_name='XMWSDJ04MMC', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'\x10Y\x03\x12S\xf0"\xa7\xf14\x1c'}, rssi=-96) match: set()
2022-12-14 21:10:13.524 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 7.458251189003931
2022-12-14 21:10:43.524 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 6.6972255559958285
2022-12-14 21:10:57.440 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}
2022-12-14 21:11:13.526 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 3.9781339790060883
2022-12-14 21:11:43.527 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 1.6850567500077887
2022-12-14 21:11:57.147 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --DEVICE MAC ADDRESS-- AdvertisementData(local_name='XMWSDJ04MMC', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'HY\x03\x12U\x8b\x87\xafl\xeb\xffL\x00\x00\x00\x88\xac9d'}, rssi=-98) match: set()
2022-12-14 21:12:13.528 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 0.24000808299751952
2022-12-14 21:12:43.528 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 7.349247507998371
2022-12-14 21:13:13.528 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 5.299178462999407
2022-12-14 21:13:43.529 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 0.20000673600588925
2022-12-14 21:14:13.529 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 0.16000538799562491
2022-12-14 21:14:43.530 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 9.000303103006445
2022-12-14 21:14:57.081 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (--BT MAC ADDRESS--) [connectable]: --DEVICE MAC ADDRESS-- AdvertisementData(local_name='XMWSDJ04MMC', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b"HY\x03\x12V\x1a\xf4\xdc~\xf5\x87:\x00\x00\x00M\xdd\t'"}, rssi=-96) match: set()
2022-12-14 21:15:13.530 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 6.220209474005969
2022-12-14 21:15:43.531 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (--BT MAC ADDRESS--): Scanner watchdog time_since_last_detection: 5.292178221003269
2022-12-14 21:15:51.166 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2022-12-14 21:15:56.170 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '--BT MAC ADDRESS--', 'sw_version': 'homeassistant', 'hw_version': 'usb:45dsf24nnFGHGdg', 'passive_scan': True, 'manufacturer': 'Realtek', 'product': 'ASUS USB-BT500', 'vendor_id': '0b05', 'product_id': '190e'}}

I'm using only one device Xiaomi BLE XMWSDJ04MMC.

I keep getting:

Rediscovered adapters: {'hci0': {'address': '.......

does that meen that my bluetooth dongle (ASUS USB-BT500) crashing frequently?

Jc2k commented 1 year ago

Potentially. Realtek chipset dongles are the mostly likely to crash.

Halytskyi commented 1 year ago

Hm... maybe I need test more time, but after upgrade to 2022.12.1 seems issue fixed in my case... Edited: ok, no, still have issue (but rarely)

baramuse commented 1 year ago

@Halytskyi May I ask how did you get your XMWSDJ04MMC working in the first place ? Via the Xiaomi integration ? I got 6 of those and can't get data readings.. I can discover them but that's about it.

Jc2k commented 1 year ago

On GitHub we have one issue per.. issue. Don't hijack existing issues, it makes it hard to track what we have and haven't resolved.

I have 4 or 5 of these from different HW revisions all working with HA. I followed the steps in the docs.

The thing that confuses people with these is if they are new, then they try to add them to HA before they have a binding key. You need a binding code before you start.

The other thing that can go wrong is if they change the bind key after HA has already detected the old one.

Failing that its usually range or a buggy Realtek chipset or out of date bluez/kernel/firmware.

kalinext commented 1 year ago

I have 5 LYWSD03MMC devices on stock firmwire + xiaomi ble integration +asus bt500 dongle. I had "unavailable" status instead of temperature and humidity values in home assistan with 1 of them, this device was too far from bt dongle. So I moved closer device and bt dongle. After that problem gone. Some time ago I made 5 automations of all my 5 devices with trigger state from state "empty" to unavailable with action notification. Absolutley all of them periodically send notification that they are unavailable, but in HA they show values. What i noticed that periodic of notification is shorter those who are farther away. But devices that are placed nearly (1-3 meters) from bt dongle stiil have that issue. Any comments what is it? wifi interference?

Jc2k commented 1 year ago

Unavailability is determined based on the cadence of updates. This is tracked per device. So your devices are missing an expected check in, therefore you have likely missed data points.

Range with Bluetooth is hard. It isn't a static thing. I found that even though they don't move around devices in my bedroom are not reachable at night time. I don't know the cause of this (maybe the phones in the bedroom?).

Adding Bluetooth proxies to my house ultimately resolved the issue.

Jc2k commented 1 year ago

My fridge sensors periodically have data missing at the moment and that is because I recently "upgraded" my Bluetooth dongle. It seems to crash routinely, HA recovers but it takes a while to notice.

(Note that both the new and the old dongle are on the supported list, so there is likely some driver or firmware issue at play - that list alone is not enough to get a solid setup).

Even USB can interfere with Bluetooth so make sure you have an extension cable etc.

kalinext commented 1 year ago

There is no missing data pionts. There is only notification that device is unavailabile that give me automatoin. I have 5 devace in total i have 5-20 notifications per 24h

Jc2k commented 1 year ago

If your device is unavailable we are not seeing data for it. Devices go unavailable when bluez can't see them or we aren't seeing transmissions for them.

Your Bluetooth dongle could be crashing, but that would impact more sensors probably. That said, auto recovery could be kicking in and resetting the dongle before they all go unavailable.

You could try turning on the signal strength sensor for one of the sensors to confirm there isn't some interference at play.

kalinext commented 1 year ago

If it would be bt500 crash I would have 5 notifications at the same time and all 5 devices would be unavailable for some time. I would see it. Wright? But i have only one unavailable message and no data points missing. (I do not see line breaks on the graph) Signal is ok 40-65 db. But i cant say what hapen with it when i get unavailable message. I guess it is some short failure that momentanly reforms may be related with neighbors wifi signals

Jc2k commented 1 year ago

It's not that straightforward. The data is collected passively. It's not like a dongle crashes and everything goes offline immediately. It's not like when your internet goes down and all active downloads die.

This is a simplification but to get the gist of it...

First, think about how every device is transmitting with the same cadence/rate but with different start times.

Now imagine a dongle crash happens but recovery is quicker than this cadence.

If you sketch on a paper when those transmissions are, and when the dongle is crashed, you'll see a crash can cause HA to miss some broadcasts but not all of them.

So you see, this means a dongle crash can cause some devices to be reported as unavailable but not all.

Jc2k commented 1 year ago

Btw the line breaks aren't always visible on every graph, especially now many of them are driven by statistics data. Sometimes I had to go out of my way to find a graph that was zoomed in enough to see the gaps when debugging stuff.

If the device is unavailable there is a "gap", the unavailable state is stored as a data point that is. If you can't see it, it just means everything recovered quickly so it's imperceptible on whatever you are looking at.

kalinext commented 1 year ago

Ok. I disable asusbt500 dongle and enable integred intel3165 bt module. I will report if there will be any differences. Also i have tplink ub500 dongle which is on not recomended list and one some kind csr 4.0 dongle. I may test thous also

kalinext commented 1 year ago

No unavailable notifications for 24h with intel bm. Then a plug in asus again and after a hour i get unavailable notification. So i can confirm that causer is RTL8761BU

Jc2k commented 1 year ago

Awesome. The RTL chipsets seem to work very poorly on Linux as a rule.

bdraco commented 1 year ago

You should expect ~80% packet/advertisment loss with an RTL8761BU with the current drivers

Charisketi commented 1 year ago

Strangely the problem does not appear after the latest upgrade v2023.2 and HA OS v9.5. I don't know if this happens to others with the same problem. It is still early but so far no thermometer has become unavailable. (Using RTL8761BU )

bstempien commented 1 year ago

I continue to see my moisture sensors go unavailable after approximately 9 minutes then within a another minute come back as dry. Then repeat. Although there are times, especially during the night that they seem to stay available.

On Thu, Feb 2, 2023, 12:03 PM Charisketi @.***> wrote:

Strangely the problem does not appear after the latest upgrade v2023.2 and HA OS v9.5. I don't know if this happens to others with the same problem. It is still early but so far no thermometer has become unavailable. (Using RTL8761BU )

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/80750#issuecomment-1414072085, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3TSEBFUKGYD7T2EWR3Y7TWVPSERANCNFSM6AAAAAARLN742E . You are receiving this because you commented.Message ID: @.***>

thunder312 commented 1 year ago

Hi guys, I have a similar problem here. After working for a few hours, my Xiaomi Temp and Humidity sensors (LYWSD03MMC) data (entities) gets unavailable. And never come back online. :-/ Device History Example Temperature

It looks like my bluetooth adapter is crashing. Log:

dan@homeassistant:~$ bt-device -l
ERROR:lib/bluez/adapter.c:165:adapter_get_dbus_object_path: assertion failed: (ADAPTER_IS(self))
Bail out! ERROR:lib/bluez/adapter.c:165:adapter_get_dbus_object_path: assertion failed: (ADAPTER_IS(self))
Abgebrochen (Speicherabzug geschrieben)

Any suggestions?

Thanks in advance, Daniel


OS Ubuntu Linux 22.04.2 LTS

Software Bluez package version 5.65

What version of Home Assistant Core has the issue? Home Assistant 2023.4.2 Frontend 20230406.1 - latest

What was the last working version of Home Assistant Core? None

What type of installation are you running? Home Assistant in Docker Container

Integration causing the issue Xiaome 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? No response

Additional information No response

Jc2k commented 1 year ago

Try unplugging and replugging your dongle or a full power restart. If that doesn't work, or you run out of patience because you need to do it so much... you'll need to buy a better dongle.

Make sure you are using one of the ones on this list.

Make sure your bluetooth firmware is up to date. We can't really help you with Ubuntu sysadmin stuff so you might want to ask the Ubuntu community about this.

Short of updating the kernel, bluez and switching to the faster dbus broker (all which I would avoid doing on Ubuntu because of the risk of making things worse) there is nothing else to try.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.