core: Bluetooth tracker LE setting up error
Home Assistant release with the issue:
0.78.0
Last working Home Assistant release (if known):
Operating environment (Hass.io/Docker/Windows/etc.):
hassio (HassOS 1.10) rpi 3
Component/platform:
Bluetooth tracker LE https://www.home-assistant.io/components/device_tracker.bluetooth_le_tracker/
Description of problem: Error in setting up the platform.
Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
device_tracker:
- platform: bluetooth_le_tracker
Traceback (if applicable):
2018-09-18 19:57:05 WARNING (SyncWorker_13) [homeassistant.components.device_tracker.bluetooth_le_tracker] No Bluetooth LE devices to track!
2018-09-18 19:57:05 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bluetooth_le_tracker
Additional information: Nothing more in log. I also have Mi Flora Plant component that works with Bluetooth LE.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 119 (27 by maintainers)
There is a problem with setting the default track_new_devices, you have to activate it yourself:
Now works for me.
Error during Bluetooth LE scan: Unexpected error when scanning: Set scan parameters failed: I/O error
in Home Assistant 0.106.5
Was able to reproduce the error by restarting home assistant while it was scanning.
When HA gets restarted while a scan is being done, the HCI0 interface is not being disconnected gracefully:
The interface is left in a dirty state, on start or restart a ‘hciconfig hci0 reset’ should be called to clean the interface.
Could @boosik and @Molodax test this by stopping HA, call ‘hciconfig hci0 reset’ and start HA again to see if it runs?
2 other issues are apparent on a fresh install:
EDIT: This is default behavior that can be fixed by adding: (ty @qubik)
fixed via #75013 in 2022.8.0 (unreleased)
I have the same setup and the same error. Did you solve the problem @xvolte ?
Same issue. Worked reliably for months on RPi4 till update to 21.3.3 or thereabouts. Now my tile BLE trackers are changing everyone to ‘away’ every few minutes.
[pygatt.backends.gatttool.gatttool] Unexpected error when scanning: Set scan parameters failed: I/O error [homeassistant.components.bluetooth_le_tracker.device_tracker] Error during Bluetooth LE scan: Unexpected error when scanning: Set scan parameters failed: I/O errorHi, how do you get that far.
i’m stuck in the logs, home assistant saying :
FileNotFoundError: [Errno 2] No such file or directory: 'sudo'i’m using hass.io on rpi 3b+ and i don’t understand how, from docker containers to leave access to bluetooth device, even when reading this doc: https://www.home-assistant.io/integrations/bluetooth_le_tracker/#rootless-setup
Home Assistant release with the issue:
0.78.0
Last working Home Assistant release (if known):
Operating environment (Hass.io/Docker/Windows/etc.):
Docker on Ubuntu Server 18.04
Component/platform:
Bluetooth tracker LE https://www.home-assistant.io/components/device_tracker.bluetooth_le_tracker/
Description of problem: Error in setting up the platform. Classic Bluetooth (not LE) is working well on the same instance in the same Docker container.
hcitool lescanworks well in the container.hcitool devshow device hci0 up and running.Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
Traceback (if applicable):
That is low. It might be higher if it were more reliable 😀
Is this for me if I’m running HAS OS on a pi4, or is this for docker container-esque setups?
Hi all, I wrote a watchdog daemon for who are running HA as supervised like me. If you are interested to try it is here: https://github.com/mcanteri/home-assistant-bluetooth-LE-watchdog
Same problem on Hass.io 0.107.7. I dont have Miflora. I tried many diffirent variants of device_tracker config but this is what i see everytime.
HASS 0.107.4 Logger: homeassistant.components.bluetooth_le_tracker.device_tracker Source: components/bluetooth_le_tracker/device_tracker.py:119 Integration: bluetooth_le_tracker (documentation, issues) First occurred: 10:44:42 PM (27 occurrences) Last logged: 10:54:27 PM
Error during Bluetooth LE scan: Unexpected error when scanning: LE Scan
I was having this issue too, and I did notice now that> track_new_devices: false cause the issue, while if I set track_new_devices: true
It is working fine.
@pvizeli, I tried your v2 component. Initially I had the same problem that @Molodax had (“Unable to install package pygattlib==0.0.4”).
I found that some libraries and packages where required:
After installing those requisites, the component started working like a charm, detecting BLE devices and storing them in the known_devices.yaml
I have a Mi Flora, I´ll try to use both components to see if there are problems
The problem is that Bluetooth and python are not the best friends. Most of exists library are very old I don’t work with our fast moving.
The old gatttlib library was to broken. I port it to a library they use the cmd line tool like Miflora. Look like that’s difficult that two library use the same command line tool.
I try to port this platform to https://github.com/pybluez/pygattlib. Maybe some one will help on it instead to workaround it 😉
i have same issue Home Assistant 2022.9.1
any debug info that i can provide to help investigate?
Hardware is raspberry pi 4 with in built bluetooth
Wow, this patches the home assistant container. Clever, but scary 😀
I’ve had problems with Bluetooth (Mi Flora and Xiaomi BLE temp sensor) since v0.9x something. It seems they finally fixed this on the RPi3 in HassOS 3.13 that just came out. You might want tio try that. It certainly solved my problems at least…
https://github.com/home-assistant/operating-system/releases
For all those still encountering this BLEError issue I have created a workaround ble_tracker.py which may work for you (works fine for me). All it simply does is correctly intercept the problematic BLEError and basically ignores it. Seems to work because each time because the ble_device_tracker module invokes a new pygatt backend instance from scratch every time it polls for new BLE devices… So if you get an error in a single poll, who cares try again next time. this tracker module seems pretty crude (which is exactly how I would have coded it lol).
Install into
custom_components/device_tracker/ble_tracker.pyMy config is:
will this work on the homeassistant docker container? That thing seems to run a stripped down (Alpine?) Linux which doesn’t have any of these libraries in it’s repositories. libboost etc.
It seems that this configuration is now (0.79.3) working (docker on linux) :
I’ve managed to workaround the issue. Create a file “/config/custom_components/device_tracker/ble.py” Paste following code to that file (only change is None check near line 47):
Now use this configuration.yaml:
I have not tested it with miflora component because I have zero miflora devices.
@gubiq nice find! I’m now getting new devices in known_devices.yaml But I have found new problem.
Looks like some devices doesn’t have names and component throws exception when that happens, because it is trying to strip some symbols from it.