tl;dr: Could bluetooth service UUIDs be used to auto-discover appropriate integrations for bluetooth based sensors?
~
Disclaimer: I’m new to Home Assistant, home automation in general, and the bluetooth protocol
I have a pair of bluetooth thermometers - they both work in basically the same way - every 30 seconds or so they broadcast a BLE packet containing a “Service UUID”, plus their data (temperature, humidity, battery, etc) in a device-specific binary blob. If I’m understanding it right, it should be possible to map “Service UUID” to “python function which takes this blob as input and returns {temperature: 12.34, humidity: 45.67, battery: 89.01}
as output”.
I started work on doing this myself in a generic “bluetooth2mqtt” kind of way[1], and the “auto-detect the correct handler for each device” part works perfectly - with that script running, I can bring my thermometer within range of the raspberry pi, it automatically detects them, selects the correct code to handle them, parses the data, and publishes the sensor data to the MQTT broker.
However… it looks like running bluetooth inside docker is a pain, so I can’t really turn it into an add-in which runs on the same box as HA; and I don’t really want to dedicate one Raspberry Pi to running HA and a second one just to read bluetooth packets. That got me thinking about doing it as an Integration; which then got me thinking about “one integration per device” vs “one integration which attempts to support every BLE device in the world single-handedly” - one integration per device sounds better, but then finding the correct integration seems like it’d be a pain - unless we can auto-discover them somehow. Hence this topic, asking if bluetooth discovery is a feasible idea.
In particular I was looking at how zeroconf / ssdp / mqtt / etc integrations get auto-discovered[2], and was thinking it’d be lovely if I could put {"bluetooth": ["0000fff0-0000-1000-8000-00805f9b34fb"]}
into my manifest.json
, and then Home Assistant would prompt to install that integration when the thermometer comes within range.
Is this sensible, or is there some horrible problem that I’m not aware of?
[1] https://gist.github.com/shish/c754815f3712775efc6bbd6b616631b3
[2] https://developers.home-assistant.io/docs/creating_integration_manifest/#zeroconf