Project:Humble Homeautomation Handling
These are some field notes while playing with sensors, pies and home assistant.
Bluetooth LE Sensors
BLE sensors, like Xiaomi Mijia, are an easy alternative to building low power with an ESP32 or similar µC. Here are some issues I ran into while trying to integrate them into Homeassistant running on a Raspberry Pi.
Most BLE sensors advertise their data via GATT packets, that can be read by anyone in range. That makes it easy to integrate them without any configuration or apps. The LYWSD03MMC however encrypts these packets and needs to be configured via a (shady) Xiaomi app to get the binding keys for decryption. To circumvent this there is a GitHub project by atc1441 with which the pairing can be done via Web-Bluetooth through a browser (Chrome worked for me; Firefox and Safari don't support Web-BT currently). There is also a custom firmware for the sensors, that can also be uploaded via the web interface. It allows for changing settings like the advertising intervals and units. When using the custom firmware with ESPhome the 'Advertising Type' needs to be set to 'Mi Like' in order to work. Homeassistant supports the custom unencrypted already as it seems.
Integrating BLE devices on (rootless) container
Passing the Raspberry bluetooth device to the container in which Homeassistant runs proved to be a bit challenging to configure. Therefore the BLE interface is done through ESPhome using the 'Bluetooth Low Energy Tracker Hub' component. Out of the box it kind of works, but WiFi connectivity is fighting with the BLE as they use the same antenna, which results in connection losses. Here are my current ESPhome settings for the BLE tracker, that kind of work.not reallyI hate Bluetooth
1 #[...] other config 2 3 esp32_ble_tracker: 4 scan_parameters: 5 interval: 100s 6 window: 120ms 7 active: false 8 9 sensor: 10 - platform: xiaomi_lywsd03mmc 11 mac_address: "XX:XX:XX:XX:XX:XX:XX" 12 bindkey: "abcdabcdabcdabcdabcdabcdabcdabcd" 13 temperature: 14 name: "Living Room Temperature" 15 humidity: 16 name: "Living Room Humidity" 17 battery_level: 18 name: "Living Room Battery Level" 19 20 21 - platform: uptime 22 name: "BLE Interface Uptime"