Adding Bluetooth LE Tracker Sensor to hassio
I've decided to add a tracker sensor so my controller generates and plays music if I'm nearby.
This tracker discovers new devices on boot and in regular intervals and tracks Bluetooth low-energy devices periodically based on scan_interval value. It is not required to pair the devices with each other. So I've changed the configuration of my hassio.
sudo vi /usr/share/hassio/homeassistant/configuration.yaml
device_tracker:
- platform: bluetooth_le_tracker
device_id: hci0
scan_interval: 60
track_new_devices: False
# track_new_devices: True
Than I've restarted the assistant, but nothing happens. And my BLE devices where not detected. I've read some bug reports and added a file, which is used by the tracker to populate new BLE devices, when track_new_devices is set to True.
sudo touch /usr/share/hassio/homeassistant/known_devices.yaml sudo chmod 666 /usr/share/hassio/homeassistant/known_devices.yaml sudo vi /usr/share/hassio/homeassistant/known_devices.yaml
I've restarted the assistant again and start getting new devices into known_devices.yaml. Than I modified names my devices. As well I've discovered that some BLE devices constantly changing their MAC address. So I've disabled tracking of new devices by setting track_new_devices to False. So This is current content of known_devices.yaml.
sudo vi /usr/share/hassio/homeassistant/known_devices.yaml
bose: hide_if_away: false icon: mac: BLE_04:52:C7:FE:AF:98 name: BOSE QC35 picture: track: true nxp: hide_if_away: false icon: mac: BLE_00:60:37:12:87:A0 name: NXP Rapid IoT D87A0 picture: track: true sport_6610: hide_if_away: false icon: mac: BLE_D4:78:09:01:66:10 name: SPORT 6610 picture: track: true
I've used the following command to troubleshot configuration by filtering specific keywords from the assistant log file:
pi@raspberrypi:~ $ tail -f /usr/share/hassio/homeassistant/home-assistant.log|grep 'BLE\|Error\|ERROR\|fail\|Discovered'
2019-05-19 00:19:42 INFO (SyncWorker_9) [pygatt.backends.gatttool.gatttool] Discovered 22:DB:51:7A:A7:B2 (None) 2019-05-19 00:19:42 INFO (SyncWorker_9) [pygatt.backends.gatttool.gatttool] Discovered D4:78:09:01:66:10 (SPORT 6610) 2019-05-19 00:19:42 INFO (SyncWorker_9) [pygatt.backends.gatttool.gatttool] Discovered 00:60:37:12:87:A0 (D87A0) 2019-05-19 00:19:42 INFO (SyncWorker_9) [pygatt.backends.gatttool.gatttool] Found 3 BLE devices 2019-05-19 00:19:55 INFO (SyncWorker_19) [pygatt.backends.gatttool.gatttool] Starting BLE scan 2019-05-19 00:20:05 INFO (SyncWorker_19) [pygatt.backends.gatttool.gatttool] Discovered 22:DB:51:7A:A7:B2 (None) 2019-05-19 00:20:05 INFO (SyncWorker_19) [pygatt.backends.gatttool.gatttool] Discovered D4:78:09:01:66:10 (SPORT 6610) 2019-05-19 00:20:05 INFO (SyncWorker_19) [pygatt.backends.gatttool.gatttool] Discovered 00:60:37:12:87:A0 (D87A0) 2019-05-19 00:20:05 INFO (SyncWorker_19) [pygatt.backends.gatttool.gatttool] Discovered 04:52:C7:FE:AF:98 (None) 2019-05-19 00:20:05 INFO (SyncWorker_19) [pygatt.backends.gatttool.gatttool] Found 4 BLE devices
Now I' can see the state of all tracked BLE devices at the assistant Devices page:
And I can as well see the history of devices and change of their states (Home<->Away)
The next step is to automate the process of sending sensor data to the music generator when controller knows that I'm at home.


Top Comments