Custom Bluetooth Connection with Python

I have an R2D2 droid by Sphero that’s long been discontinued. After a lot of custom dev on this little guy, I was able to connect to him using a python bluetooth library. Some gracious soul sniffed the traffic and wrote a wrapper so I can send it commands. I did that and then had the script register a custom MQTT device in HA. So, now it can receive commands from HA and report back certain things. I took it a step further and wrote a wrapper around all the python using my native language (F#).

Now, I would like to try and get this working natively using just HA. However, I cannot get the bluetooth integration in HA to force a connection to R2 and I don’t think it would just magically know what commands to send/use, so I know I’ll have to stick with my python script but not sure how to tie all these things together. Does anyone have any ideas?

2 Likes

Hi, can you give a little more details for this? i just got an R2-D2 droid and i would love to connect it with HA somehow

I have one too. If I could have this thing to ‘beep bo’ when something in HA happens, the family would freak out! lol Would be awesome if this was in HACS.

@TeDeVPrime and @bptworld Sorry for the late reply! I have been quite distracted lately and HA took a back seat. I would be happy to help you get setup! You can find me on discord! I sent you both a DM with my email.

@TeDeVPrime and @bptworld - Here’s a screenshot of my R2D2 running in HA.

@fischgeek can you share a little more detail on how to set this up? I’ve been digging into how to do this with my setup.

It’s more of a hack really than an actual integration. I modified a python library that talks to the droid and put in all the necessary MQTT config to have Home Assistant pick it up as a device.

I have the python script running on my HA machine (not in HA) with a Bluetooth connection to R2. When it finds and connects to the droid it starts sending/receiving MQTT communication.

Mind sharing the script? I’ve been trying to figure out how to make this happen with my little R2 so I can use it for notifications and such.

Yeah. Let me go through it quick and clean up some stuff. I’ll shoot you a repo soon.

1 Like

See if you can get going using this repo. It’s my fork of a library I used it to get started. I modified it a bit to fit my MQTT needs for the HA integration. I was going to modify the library directly, but decided to just make a couple .py scripts for the MQTT/HA integration.

Since I don’t have very much experience with Python packages and distribution I’m trying my best to put what I did into a repo for you to look at. So, apologies for the delay.

1 Like

Thanks! Much appreciated!

I have a R2 as well. Is there any progress @fischgeek , @TechyWill

@eric1905 or @TechyWill - Feel free to DM me and we can chat about it there.