New to the forms so please feel free to tell me I’m posting in the wrong place etc. no offence will be taken.
I’m looking for advice and pointers on the “best” way to go about designing an integration that tracks some data from my smart toothbrush (one of the Braun Oral-B bluetooth toothbrush).
I’d like to track:
Battery
Last seen in use (or general on/off tracking)
Last duration
I’ve got a proof of concept up and working by gutting the bluetooth le tracker, replacing the blutooth library with pyblue and then pounding on it with a wrench until I was able to interrogate the device and obtain the data.
This works and I can now see the battery and presence detection from the device_tracker platform. Smashing.
So next I wanted to:
Learn a bit more about home assistant integrations
Possibly build something that others can benefit from
I feel that using the device_tracker platform is possibly a little bit nasty but I’m new to the home assistant world so it’s unclear to me what a better architecture for my integration would look like.
One of the things is that the device is only available for interrogation shortly after it has been used. Ideally I would have a process scanning or listening and then update the state of, say a battery sensor platform.
Any pointers and advise would be gratefully received.
Also, sorry if I’m using the wrong nouns for platform/integration etc. as I said, I’m new to this and it trips me up occasionally
Thank you nick, I’d thought about something like an esp32 but wanted to leverage the bluetooth on the RPi.
Thanks for the pointers about RTFM and the code. Indeed I’ve been using both of these as a guide. I think one thing that I’m still unsure about is how a subscription (vs polling) model would work if I had a python class that could notify on updates.
The device_tracker integration appears to be a mix of “legacy” and I guess “modern”. Does anyone know of a summary of what would be considered legacy vs modern in general for HA? Lots of newbie questions, thanks in advance.
Nearly smacked my forehead at the prospect that I had missed an existing integration. Upon a quick inspection of the code it looks like the battery level isn’t supported (and it’s unsurprising because it was rather a pain in the proverbial to get it working). I’ll look at maybe creating a PR with the battery included.
I think I now have more newbie questions…
Why would one favour building the integration externally like this rather than using the integration components framework (again sorry if I’m butchering the nomenclature) within home assistant?
I note that the above gateway is intended to run as a docker container, I wonder if it will run as an addon with appropriate effort.
Enjoying learning about home assistant (even if I now completely hate all bluetooth devices).
Oh, I’m fully aware of this. However I thin the shark was jumped when the manufacturer put Bluetooth in the toothbrush to begin with
There is a genuine use-case out of all of this, it’s a perennial problem that we end up with a flat toothbrush because on one realised it was low on battery. Having the value in home assistant means I can trigger an alert off the back of it.
Just started a Python package to read out electrical toothbrushes via Bluetooth LE.
Currently it only supports Philips Sonicare - however, it is pretty simple to extend and add other toothbrushes as well
It could be the basis for a Home Assistant integration of toothbrushes. I’d love to receive some feedback and maybe even some PRs!
that’s pretty cool since I also have a Philips Sonicare! I’d want to start different routines once i brush my teeth or after I’m done with brushing my teeth.
Any progress on this? I made the oral-b Home Assistant specific worker for zewelor bt-mqtt-gateway in the past and checking on https://github.com/Hypfer/Cybele
Having a library like SteinRobert is making would be nice so it could be integrated in a more clean way into bt-mqtt-gateway and Home Assistant and it could allow me to detect brushing sessions through the whole house