Closed Yersi88 closed 3 years ago
Looks like some hardware error. What do you use for Bluetooth, a dongle or internal BT?
Looks like some hardware error. What do you use for Bluetooth, a dongle or internal BT?
This dongle: https://www.amazon.co.uk/gp/product/B07NQ5YGDW?psc=1 And it is on 1.5 m USB extension cable.
Internal bt never worked (only if thermometer was laying directly on the pi) and dongle plugged in directly into port never worked as well. Only solution that works is dongle on long usb extension.
That is the same dongle I use. It might just be broken (hardware failure). I've never seen this error, but maybe someone else has seen this before?
@Yersi88 do you use this dongle for anything other than collecting data from sensors with ble_monitor integration?
@Yersi88 do you use this dongle for anything other than collecting data from sensors with ble_monitor integration?
Just this integration, nothing else. As far as I know.
The "unknown link type" messages are alarming. I am not a great expert in these matters, but I suspect that some device "probes" your adapter, which leads to an error somewhere at the low level of the bluetooth stack (possibly due to some kind of a bug there). The only thing I can suggest at the moment is to try to disable all adapter features except necessary for the integration to work (you will need root access to the host shell), that is, run the following commands:
btmgmt --index 0 info
btmgmt --index 0 power off
btmgmt --index 0 bredr off
btmgmt --index 0 power on
btmgmt --index 0 bondable off
btmgmt --index 0 sc off
btmgmt --index 0 ssp off
btmgmt --index 0 info
the result should be as follows (btmgmt info
, under current settings:
remains only powered
and le
):
hci2: Primary controller
addr 28:37:37:15:3E:58 version 6 manufacturer 15 class 0x000000
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr
current settings: powered le
name mini2x14
short name
hci1: Primary controller
addr 00:1A:7D:DA:71:11 version 6 manufacturer 10 class 0x000000
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr
current settings: powered le
name mini2x14 #2
short name
hci0: Primary controller
addr 00:00:00:00:00:00 version 10 manufacturer 1521 class 0x000000
supported settings: powered connectable discoverable bondable le advertising secure-conn debug-keys privacy static-addr
current settings: powered le static-addr
name mini2x14 #1
short name
However, it should be noted that these changes are not permanent, you need to add these commands somewhere in the autorun. I don't know how best to do this in the case of Home Assistant OS... Moreover, bluetooth daemon service must be stopped and disabled.
@Ernst79 I can’t find a link to the method for obtaining root access to the HassOS host... Do you have it at hand?
The way to get root access on Home Assistant OS is explained here https://developers.home-assistant.io/docs/operating-system/debugging/
I found that this also fixes it: 1) bluetoothctl power off 2) bluetoothctl power on 3) reload the integration.
Yes, it often helps ) Basically, this is the same as pulling and inserting a dongle and reloading the integration.
Yes, it often helps ) Basically, this is the same as pulling and inserting a dongle and reloading the integration.
I was wondering if it would be possible to make automation that does this steps when this happens?
I think someone did this before,
Check this post, restarts Bluetooth with a script. He didn't need to restart the integration.
https://github.com/custom-components/ble_monitor/issues/345#issuecomment-847002258
RaspPi 4B+ with HASS I bought 5x different dongles and tried each. Same problem. Randomly from 1min to few hours it's just stop working. In log i see: HCIdump thread: Runtime error while stop scan request on hci0: Event loop stopped before Future completed. Anyone know working dongle? I can buy 10x more, just tell me which one will with with RaspPi 4B+ with HASS.
@klim123123 the hci0 interface is most likely the interface of the module built into the raspberry. Try to enable only one (external USB) interface in ble_monitor settings.
@Magalex2x14 yes sorry, i copied this text from wrong window. my error is about hci1. HCIdump thread: Runtime error while sending scan request on hci1: Event loop stopped before Future completed.
i always select external interface and reboot host after applying settings. i can't use my internal bt, because i have aluminum box and i get very low signal level. if i disconnect external bt dongle and try to use internal bt, there is no any errors for days. after i connect any of my external bt dongles, selected interface, reboot. i get his error some times in just a minute, sometimes in few hours.
now sure what to do. looking for any working bt dongle for HASS.
@klim123123 if you have tried many modules already, then most likely it is not about them. The reasons can vary - from the bugs in the Linux kernel modules to problems with power supply... Power supply problems should not be dismissed - the rpi4 is a very power-hungry device (especially if you use external drives such as SSD or other power-hungry peripherals)... Do you see errors similar to those in the first message of the topicstarter? Are you using other integrations that work with Bluetooth? Do you have the opportunity to try connecting a BT-dongle through a powered usb-hub? Also describe which modules you have tried (these were several identical modules of the same brand, or different modules from different manufacturers) - it is quite possible that we have positive user reviews about one of them, and then we will know for sure that the problem does not lie in this plane.
In previous messages, I raised the topic of "probing devices" for a reason - I myself faced this problem (a neighbor's android smartphone regularly hung up my bt-interface). There is no solution to this problem other than waiting for fixes in the Linux kernel or the methods described above. My solution with disabling all capabilities of the bt interface except BT LE has been working for me for a long time. However, I have no objective evidence that it was it that solved my problem...
@Magalex2x14 just tested with powered usb-hub. it's worked for 20 hours and got the same problem. I'm not using any integrations that work with Bluetooth.
Not sure how to get same error message in terminal. Do i need to leave it open until i get hci1 error? (just restarted experiment with opened terminal window)
I have this in logs: [66155.127892] Bluetooth: hci1: Received unexpected HCI Event 00000000 [66155.222932] Bluetooth: hci1: hardware error 0x7f
This is my dongles:
@klim123123 I don't know what to advise you... The situation is sad. You can endlessly sin on hardware and power problems, and continue to spend money, but the problem may actually be in the software part of the operating system (the Linux kernel, kernel modules and firmwares). The only thing I can say is that it looks like Bluetooth 4.0 modules have more stable support in Linux than BT5.0. It is also saddening the fact that the HomeAssistantOS developers some time ago switched to a fairly fresh kernel of the 5.x branch, in which, judging by the reviews on the Internet, there are many problems with Bluetooth...
If I were you, I would probably go the following way:
I would make sure that everything is fine with the power supply of the raspberry (I would measure the voltage at the board power input under the load). If the voltage under load was below 4.8 volts, then I would take action. Here I want to draw your attention to the fact that this is a general requirement for the stability of the system, and objectively may not be directly related to your problem, and this is a topic for a separate conversation, but I will continue, since I have already started ). The rpi4 specs states that the power supply must provide a current of 3 amperes. You cannot rely only on the characteristics of the power supply - you need to take into account the real characteristics of the power cord. Nowadays, one cannot be completely sure of the honesty of sellers, so I prefer to rely on the results of measurements... You can compensate for the voltage drop on the power cord by raising the voltage on the power supply or replace power cord - note that the power supplies recommended by the manufacturer for the rpi4 supply more than 5 volts (5.1 volts, for example. There are even models with 5.25 volts).
As the second point, I advise you to use crutches :) There are two options: try my method, or the method with resetting the bluetooth module using a script. The second method has been repeatedly discussed in issues on our repository (including current issue). In any case, ideally you should be familiar with Linux, and have skills that often go beyond the usual user experience - you will need to organize root access to the host shell, and you need to be prepared for the fact that with the next HomeAssistantOS update, you will have to make these changes again.
I bough my 7th dongle and looks like i found working dongle! Asus USB-BT500. I still get errors in log, but everything continue to work! Looks like dongle restarting itself after crash. I have no any messages in opened terminal window. I will update this message. Now i tested it for ~30 hours. Edit: After ~40 hours, dongle stopped working.... It was connected to usb hub. I just connected it directly. Started new test... Edit2: I'm getting many many hci1 errors in log, but dongle continue working. Edit3: Okay, problems still exist. Sometimes in ~12h, sometimes in 40h+ dongle stop sending any data.
There seems to be a HassOs 6.2 update, that updates the Bluetooth firmware on Raspberry PI. Don't think it will help for you, as you are using external dongles, but just though I should mention it.
Are there any easy method to understand that dongle is stopped to send any data? So i can do bluetoothctl power off bluetoothctl power on
upd: Here is the solution to auto restart for hassio.
Edit configuration.yaml and add following: shell_command: bt_off: bluetoothctl power off bt_on: bluetoothctl power on
Go to Configuration-Automations and create new Trigger type: State Select Entity of your bluetooth device sensor. Attribute: Last packet ID For: 00:30:00 this is for 30 minutes if no update of value. You can change it.
Actions. Add call service: Shell Command: bt_off Add delay 1 second Add call service: Shell Command: bt_on
Also you can add to send notification to Telegram or similar. Done
I have RTL8761B based dongle and installing original Realtek driver helped in my case (20201202_LINUX_BT_DRIVER, downloaded from https://www.xmpow.com/pages/download, look for USB adapter -> BH519A) I am on Ubuntu 20.04.1 with hwe kernel which has recently been updated to 5.11 and broke the btusb driver.
version 5.6.2 will now automatically reset the Bluetooth adapter in case of a failure. (power on
and rfkill unblock
). This should at least be a workaround to restart the Bluetooth adapter when it fails. To discuss the actual underlying problem further, please continue in #295. I'll close this issue.
My data flow randomly stops like this:
There's a errors like this in terminal:
Only full reboot of raspberry pi will resolve this situation.