Bluetooth device battery level

113 views
Skip to first unread message

a b

unread,
Nov 1, 2022, 5:31:24 PM11/1/22
to Automate
Hello,
I've been looking for a way to automatically monitor battery level in my BT headphones. I found an old thread where I learnt that it's on a To-Do list (and that the implementation is blocked due to bugs). 
Digging further I stumbled upon Home Assistant community thread that presented the name of Android intent "android.bluetooth.device.action.BATTERY_LEVEL_CHANGED". That was it - quickly drafted flow with block "Broadcast receive" proved this approach to be working. The drawback is that battery level cannot be read on demand, only when the broadcast is sent. The good part is that this info is broadcast at the moment of connection of BT device, so as soon the headphones are connected Automate gets fresh info on the battery state (and hopefully on every subsequent change of battery level - didn't have the patience to wait for discharging to see how often the broadcasts are sent).
I hope this may be helpful to someone.
Regards

Henrik "The Developer" Lindqvist

unread,
Nov 1, 2022, 6:12:31 PM11/1/22
to Automate
Try enabling the Use sticky option.

SM7

unread,
Jan 24, 2023, 2:47:42 AM1/24/23
to Automate
I've been looking to monitor battery of my BT devices too. Can someone tell me how to set up the "Broadcast receive" block for this purpose? What are the input arguments and which output variable has the battery level? Thanks. 

Henrik "The Developer" Lindqvist

unread,
Jan 24, 2023, 10:51:35 AM1/24/23
to Automate
Simply set the Action field to "android.bluetooth.device.action.BATTERY_LEVEL_CHANGED", click fx icon and type it with quotes, also assign a name to the Extras output variables, e.g. extras
The battery level value should then accessible as extras["android.bluetooth.device.extra.BATTERY_LEVEL"]

SM7

unread,
Jan 25, 2023, 3:34:17 AM1/25/23
to Automate
thank you!!..this works at the moment of connection of BT device and on every subsequent change of battery level as well.

P. Andreas Schmidt, IVE

unread,
Jan 25, 2023, 7:31:57 AM1/25/23
to Automate
There's already a flow on the community

P. Andreas Schmidt, IVE

unread,
Jan 25, 2023, 12:29:09 PM1/25/23
to Automate
And on my LG Velvet 5G I can have 2 devices connected simultenously (but the audio will only go through one), but this method will only show the battery for the last connected. I haven't waited for a drop in battery to see if it would report on both (and then you wouldn't know which), or just the latest. The bluetooth connection icon above will only show one battery symbol, for the latest; in the settings you can see both battery levels. But perhaps there's some other broadcast, seeing this device supports two devices connected... Would have to do some digging.
Reply all
Reply to author
Forward
0 new messages