Hi, I have a couple of mmWave presence/occupancy sensors that periodically broadcast their measurement data over BLE: whether occupancy is detected or not, how many people are present, and x/y/z coordinates of people relative to the sensor. I'd love to have this supported in Home Assistant, but it's not 100% clear to me where to start. Any pointers?
#mmWave occupancy sensor with BLE
1 messages · Page 1 of 1 (latest)
my first thought would be to use esphome on an esp32. i think using ble_client
documentation here - https://esphome.io/components/ble_client.html
however further discussion for that method would probably be better at home on the esphome discord.
Hmmm... thanks for the suggestion. I'm not sure that I see the added value for that route though. Home Assistant already receives the broadcasts on a USB BT dongle (maybe I should have mentioned that), so my thought was that I only need to write some Python code to hook into that. There must be a way to write an integration that hooks into bluetooth? I'll dig a bit deeper.
I guess that I should start with https://developers.home-assistant.io/docs/core/bluetooth/api/ along with the generic examples about writing an integration
If the data is in a BLE advertisement then take a look at something like xiaomi-BLE for inspiration
That's a good pointer, thanks @stray hill. It appears more complicated than I hoped, with the components/xiami_ble/* combined with the xiaomi-ble package.
Out of curiosity: why is the whole xiaomi-ble parsing stuff in a separate library, outside of Home Assistant, even though it appears to be coupled with Home Assistant specific concepts? For example, it imports BluetoothServiceInfo from home_assistant_bluetooth and does some imports from sensor_state_data.
So it’s rule that an integration codebase should just be about integrating
And we try to enforce that for core
In general that’s great, you can use that library outside of HA for other projects and it increases the community for that library. It might get used by another project and enable collaboration. It also derisks reverse engineering. The satellite lib is the one that will get the dodgey take down notice.
Integrations are really just meant to be basic plumbing rather than the whole shebang. In practice that’s not always true but it’s the goal.
Ah, yes, that makes sense
sensor_state_data is not actually HA specific, it’s just a common model and language for describing sensor data. HA still has to convert it into its internal model. That code is unfortunately boilerplate-y..
home_assistant_bluetooth - it’s been a few since I worked on it. But the direction was that we would pull the Bluetooth stack out of HA
Our main Bluetooth library is called bleak
It’s nice but it doesn’t understand esphome proxies
It doesn’t understand having multiple proxies working together
How to effectively roam between them for mobile devices etc
So there are a bunch of loosely related libraries to enable that. They don’t depend on Ha itself though.