BLE device tracker stops after an hour or so "unexpected error when scanning"

Hi all,

I use the standard BLE device tracker in Hassio (HassOS 2.12 / Home Assistant 0.93.2, running on a Tinkerboard). I use it to track my Tile to see if some one is home. I will use it next to my Wi-Fi based device tracker to be 100% sure someone is home.

Unfortunately the device tracker only works for a few hours. Than I will get the error: “unexpected error when scanning”. That’s all…

Does anyone know what causes the error and if there is any thing we can do about it? I read that a lot of people are struggling with BLE/Bluetooth. Some use a MQTT/BLE gateway but I’m not fan of an extra device of gateway as it is built in in Hassio.

My config:

device_tracker:

  • platform: bluetooth_le_tracker
    track_new_devices: false
    consider_home: 180

Thank you in advance!

Mark

I also tried the settings below today.

  • platform: bluetooth_le_tracker
    track_new_devices: True

It works longer but still it crashes.

I also tried the settings below today.

  • platform: bluetooth_le_tracker
    track_new_devices: false

  • platform: bluetooth_le_tracker
    track_new_devices: False

It works longer but still it crashes. Looks to me like a bug.

The lastest version 0.94.0 of hassio doesn’t fix the problem either.

Before 0.94.* I’ve had a custom_component bluetooth_le_tracker, a modified version that does the error handling a little bit differently, so it doesn’t stop after running once or twice. Worked like a charm! But sadly with 0.94.* that broke and the custom_component doesn’t load anymore.

So, baseline: same here - the bluetooth_le_tracker scans a few times, maximum for 10 minutes, and then my trackers fade to “not_home”.

Possibly related: eq3btsmart climate devices, which also work with BTLE, are wonky since 0.94.*, too. I have 6 of those, 3 show up, the other 3 can’t be reached.

Anyway, right now the bluetooth_le_tracker is unusable.

Thanks for your message. I will make a bug report. Hope they will fix it…

I was using the custom component ble tracker too. I upgrade to 94 and the component just crapped out. I have taken some changes from the custom component and added them to the official component and this seems to work for me now. Going on 24 hours now. The code is at

https://github.com/davefrooney/custom_components/tree/master/ble_track

I hope this helps

3 Likes

It does indeed - so far BTLE-scanning keeps on going and doesn’t bug out. My gf is still shown as home and I don’t get any notifications whenever the housedoor is opened. Very nice, thank you very much!

PS: on a side-note: all 6 eq3btsmart climate devices are back, too!

Great to hear. All my automation rely heavily on BLE so I had to get it working

have i any todos to activate this custom_component? I past the folder ble_track to my custom_component folder but not sure that it works (per now i have the same problem that the devices not found but hcitool -i hci0 lescan shows that the devices were found). have i activate this and/or deactivate the standart hass ble component? it were great if it is possible to install and update this over HACS?

Have you added your devices to known_devices.yaml?

I can create a separate repo for this which you should be able to manually add to HACS

1 Like

Hello,

I have copied the 4 files from @davefrooney ble_track folder, not the ‘custom_components\ble_track’ that is 6 months old. Is it ok?
And added to ‘configuration.yaml’:

device_tracker:
  - platform: ble_track
    track_new_devices: false
    interval_seconds: 15
    hci_device: 'hci1'
    consider_home: 45

But when going to fully restart HA, I get a '

> Config error. See [the logs]

with this message:

> Platform error device_tracker.ble_track - Integration ‘ble_track’ not found.

What am I doing wrong?

Info: Hassio is installed under docker, in a Intel NUC pc in a VMware virtual machine. Intel NUC integrated bluettoth adapter seems not compatible with LE function. So I have connected an USB external BT 4.0 dongle adapter.

UPDATE 1: Solved, now I can restart, and I suppose that ble_track is running. But the same error appears at log:

2020-04-04 18:21:14 INFO (SyncWorker_8) [root] Sending handshake.

2020-04-04 18:21:19 INFO (SyncWorker_6) [custom_components.enigma] Enigma: [update] - request for host 192.168.1.143 (Vu+ Solo2)

2020-04-04 18:21:21 INFO (SyncWorker_7) [pygatt.backends.gatttool.gatttool] Starting BLE scan

2020-04-04 18:21:21 ERROR (SyncWorker_7) [pygatt.backends.gatttool.gatttool] Unexpected error when scanning: Set scan parameters failed: I/O error

2020-04-04 18:21:21 ERROR (SyncWorker_7) [custom_components.ble_track.device_tracker] BLEError during Bluetooth LE scan: Unexpected error when scanning: Set scan parameters failed: I/O error

The BT dongle is HCI1. Is the ‘hci_device: ‘hci1’’ accepted?

yes i have it but it seems to be that the Bluetooth environment is problematic. now i’m testing monitor.sh on a Raspberry and MQTT, Appdemon and Monitor App on my HA environment (on Ubuntu VM).

I am running this on a Pi 4 and it is rock solid. I did have some issues on a Pi3b previously which I think was down to resources. What spec were you running on?

I am running on HASSOS on a Pi4 using the built in BLE. It is running solid for me.

Is it detecting your devices at all?

Are you also running the standard bluetooth_tracker, or anything else that uses Bluetooth?

I have found that using two Bluetooth dongles, one for bluetooth_tracker and another for the le tracker doesn’t result in those errors and le tracking is now solid.

I’m running hassos on an esxi vm on an Intel nuc.

Hello, I am also running Home Assistant on Pi4 using buid in BLE. But I am constantly getting the following errors:

2021-03-19 19:14:49 ERROR (SyncWorker_8) [pygatt.backends.gatttool.gatttool] Unexpected error when scanning: Set scan parameters failed: I/O error
2021-03-19 19:14:49 ERROR (SyncWorker_8) [homeassistant.components.bluetooth_le_tracker.device_tracker] Error during Bluetooth LE scan: Unexpected error when scanning: Set scan parameters failed: I/O error

Any idea how to troubleshoot this issue or how to fix it?

Are you using the custom component or the original HA integration?

Same issue. Worked reliably on RPi4 till update to 21.3.3

[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 error

Problem is that when it fails, it marks all our Tile trackers away (not using Tile integration, using BLE Tracker). This means HA thinks we’re away and turns everything off.

Screenshot 2021-03-20 at 22.24.15

It looks like you’re using the HA integration. Have you tried the custom component?