Hello everyone! I wanted to share a solution I came up with for displaying the battery level of my Mi Portable Bluetooth Speaker in Home Assistant. I’ve been using MPD on Debian to play music, and while the speaker itself shows the battery level when connected to my phone or computer, I wanted to integrate this information into my smart home setup for better monitoring.
I stumbled upon the bluetooth_battery tool, which allows you to check the battery level of Bluetooth devices. However, getting this information into Home Assistant wasn’t straightforward. Here’s how I made it work:
-
Install Required Packages: I started by installing the necessary Python dependencies using
pip3 install bluetooth_batteryand some system packages likelibbluetooth-dev. -
Create a Script: I wrote a simple script to run the
bluetooth_batterycommand and save the output to a file. This script is set to run periodically using cron to ensure the battery level is updated regularly. -
Set Up Home Assistant Sensor: Using the command line sensor platform, I configured Home Assistant to read the battery level from the file created by my script. This way, I can monitor the speaker’s battery status right from my dashboard.
This setup has been working perfectly for me, and I thought it might be helpful for others who are looking to integrate similar Bluetooth devices. If anyone has alternative methods or improvements, I’d love to hear about them! Let’s keep sharing and learning together. ![]()