24

I am trying to check the battery level of my wireless headphones from the command line. I came across a few discussions, and it seems all I need to do is enter the following:

ioreg -c 'deviceName' |grep -i batterypercent

I tried this command using "Powerbeats Wireless" and "bluetoothaudiod" for the 'deviceName''s, but neither returned the batterypercent. I tried ioreg -c bluetoothaudiod |grep -i battery to get general information about the battery, and get this as a response:

| |   +-o AppleSmartBatteryManager  <class AppleSmartBatteryManager, id 0x100000250, registered, matched, active, busy 0 (0 ms), retain 7>
| |     +-o AppleSmartBattery  <class AppleSmartBattery, id 0x100000252, registered, matched, active, busy 0 (0 ms), retain 6>

If I connect the headphones to my iPhone, the battery level immediately pops up on the toolbar. This leads me to believe that the device is broadcasting battery level, and that I should be able to access this information from my computer.

How can I check the battery level of my bluetooth connected headphones?

Edit:

Initially I thought the issue was with the device name, but it seems "Powerbeats Wireless" and bluetoothaudiod work interchangeably. Just can't figure out how to access the batterypercent param.

Edit 2:

Looking at the Bluetooth docs, it seems there's a Battery Service which exposes the Battery State and Battery Level. The Battery Level can be read using the GATT Read Characteristic Value sub-procedure, so I need to figure out a way of interfacing with this service from the command line. I have a feeling batterypercent may only be coded for standard peripherals (trackpad, mouse, keyboard), as all battery monitoring widgets I've tried are only compatible with such devices.

Edit 3:

Revisiting this almost a year later. I know have a wireless trackpad & keyboard, and can see their battery levels perfectly fine ( in both the toolbar or the command line). Still unable to get the battery level from my headphones though, and not sure why :/

  • ioreg -c "Powerbeats Wireless" |grep -i battery also returns the general battery info, so i think i have the correct device name. But why is the batterylevel command not working !! Smh – pingo Nov 11 '15 at 19:39
  • Please edit your question instead of commenting on your own question. – At0mic Nov 11 '15 at 19:46
  • @IronCraftMan edits are now complete. You think you could offer any help? – pingo Nov 11 '15 at 20:03
  • Hi - I'm interested in hearing if you got any further. I want to get the battery life out of PS4 controllers connected by BlueTooth to my iMac. – dunxd Mar 4 '16 at 10:33
  • Doesn't work for my JVC bluetooth headphones either. Strange, because my 5-year-old iPhone 4S has no problem telling me their battery level when connected. – John Smith Apr 11 '17 at 1:07
7

You need to use ioreg. You'll need to know the name of the device. Just follow this guide.

The guide, in short, basically has you run the ioreg -c <devicename> |grep '"BatteryPercent" ='

Example:

ioreg -c BeatsBluetoothHeadset |grep '"BatteryPercent" ='

enter image description here

Additionally, you could retrieve broader battery information with:

ioreg -c BeatsBluetoothHeadset |grep Battery
  • 2
    Hey, thanks for your response! This problem seems to be specific to the Beats headphones, as I can access battery levels for my wireless keyboard & trackpad. Will update the original question! – pingo Aug 16 '16 at 17:49
  • it's not working for me – Jadda Jun 2 '17 at 15:24
7

On my iMac(macOS 10.12.6), none of solutions mentioned above works. After reading the man page of ioreg. The solution that works on my computer is:

// the -r option is used to reduce output
// the -l option is used to display properties for all object
// by default some object properties are not shown
// the -c specify device class, the class could be specific or general
ioreg -c AppleDeviceManagementHIDEventService -r -l
ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i battery

// instead of using device io class, you could also use a property key to query
// you need to know one of target device's property key(-k), for example it is BatteryPercent for Bluetooth keyboard and mouse
// any device with this property will be listed
ioreg -r -l -k "BatteryPercent"
ioreg -r -l -k "BatteryPercent" | grep -i battery

There are some other device classes to try for the -c argument: AppleHSBluetoothDevice AppleHSBluetoothHIDDriver AppleMultitouchMouseHIDEventDriver AppleHIDKeyboardEventDriverV2, they give different output.

1

I just discovered that to check the battery level of my powerbeats 3 on my Mac I just go to the bluetooth menu in the icon area in the top right of the screen, hover over your connected powerbeats and then it shows the battery level right there. Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .