BLE tracking with Raspberry pi 4

Hi,

Is this possible using Raspberry Pi’s built in Bluetooth? Can anyone tell me which component/add-on I need to do this?

Do I need this device tracker?

I’ve tried adding:

device_tracker:
  - platform: bluetooth_le_tracker
    track_new_devices: false

But nothing seems to be added to known_devices.yaml, nor to the states section of the developer tools. I’m obviously doing something wrong; but it’s not obvious what!

Did you install pybluez on the host machine?

Maybe also change
track_new_devices: false
to true :wink:

Thanks for the response.

I don’t think I can install pybluez on a Hass.os device. I’ll look into it.

Re: track_new_devices. I don’t think that should prevent devices showing up in known_devices. The documentation says:

Note that setting track_new_devices: false will still result in new devices being recorded in known_devices.yaml , but they won’t be tracked ( track: false ).

That’s here. :slight_smile:

That’s the problem, the doc states that it is required.

You’re right about track_new_devices, never used this, so I assumed it won’t detect new devices :rofl:

Thanks - I guess my understanding that Hass.io/hass.os included all necessary dependencies was not correct for Bluetooth. That’s a bit surprising - especially as there is (sketchy) evidence that people have used Bluetooth tracking on hassio in the past.

That’s why I’m asking the question really - the whole things a bit unclear! :slight_smile:

Do you get any errors in the log? As far as I know it is not possible with HassOS.
Hass.io can also be installed on top of a normal raspbian image and then you are able to install pybluez, that’s why there are people using bluetooth tracking with hass.io.

I do not get any errors.

Thanks - well, that does explain it but it’s a bit of a surprise!

Hi @jamesking , I’m also interested in the answer. I’m running HASS.IO on Pi3. Normal Bluetooth tracking is working and I see entries in known-devices, however I can not detect any BLE devices. I’m trying to get the Xiaomi LCD Temperature sensor working which operates over BLE. I’ll update this thread if I find a solution.

May be worth checking this thread…

https://community.home-assistant.io/t/ble-custom-component/48355

I got this working. I’m afraid I can’t remember how but I will post the relevant yaml when home. I think it is no different to the above, except I had to then go and manually change items in known_devices.yaml to track: true.

@jamesking James, If you do get a minute I’d appreciate you sharing your solution. Thanks Trevor

I’ve taken another look at my set up yaml. I didn’t do anything in particular except add:

device_tracker:
  - platform: bluetooth_le_tracker

@jamesking I have that config, thanks, I’ll keep researching.

Maybe I did a host reboot too.

If you have track new devices set to false anywhere, you’ll have to manually edit known_devices.yaml

I setup ssh 22222 on my rPi4 and ran bluetoothctl > scan on

I am able to find my xiaomi miflora sensors but I can’t seem to get them to show up in HA. I don’t think the sensor or plant setup in the configuration is the issue since it was working on a laptop previously.

There are a lot of hci0 errors in the dmesg output. Any thoughts on where to go from here?

Solved - installed version 3.4

@jamesking I’d like to track devices using BLE too on Rasp 4. Did you get it working without installing pybluez? Or how did you do it? I think I have the same setup as you.

Thanks!

Hi All,

I struggled to get Bluetooth LE working on my PI3, in the end the solution was simple, I paired the device to my phone and then copied the MAC address. Hopefully this works on a PI4.

I put the MAC address in the known_devices.yaml like so:

Tag:
  icon:
  mac: BLE_FF:FF:83:5C:NN:NN
  name: Tag
  picture:
  track: true

To test I created a test person and added the device to that person in the GUI. It then showed as Home or Away in Lovelace.

I’m a newbie at this, so I hope this information helps others.

2 Likes

Hi All,

I was trying to run BLE scanning on my PRI4 with HA running in a python venv.

I installed bluez with an apt command.
So my user can run hcitool lescan command and see devices.

But there are plenty of the following log records in the HA:

ERROR (Thread-4) [custom_components.ble_monitor] HCIdump thread: Something wrong - interface hci0 not ready, and will be skipped for current scan period.
Oct 28 11:19:26 home hass[382]: 2022-10-28 11:19:26 ERROR (Thread-4) [custom_components.ble_monitor] HCIdump thread: Trying to power cycle Bluetooth adapter hci0 {mac address here}, will try to use it next scan

As a result, there are no known_devices.yaml file and it seems like the scan doesn’t work.

Could anyone suggest me how to solve my issues and make the ble scan to work?