Check the battery level of connected bluetooth headphones from the command line 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  &lt;class AppleSmartBatteryManager, id 0x100000250, registered, matched, active, busy 0 (0 ms), retain 7&gt;
| |     +-o AppleSmartBattery  &lt;class AppleSmartBattery, id 0x100000252, registered, matched, active, busy 0 (0 ms), retain 6&gt;


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 &amp; 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 :/
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.