iPhone / iPad Battery Levels?

Has anyone been able to get iPhone & iPad battery levels over WiFi?

I was able to get the battery levels when connected to my mac with libimobiledevice and the code below (but couldnt figure out how to do it over wifi)

set iphoneId to "<YOUR_IPHONE ID>"

set allDevices to do shell script "/usr/local/bin/idevice_id --list"

if allDevices contains iphoneId then

set batteryPercentage to word 2 of (do shell script "/usr/local/bin/ideviceinfo -u <YOUR_IPHONE_ID> --domain com.apple.mobile.battery | grep \"BatteryCurrentCapacity\"")

return batteryPercentage & "%"


return ""

end if

Getting iOS device bettery level over wifi should be possible since Coconut Battery and Batteries Widget is able to do so.

Anyone have any ideas on this? Thanks!

Finally, I am sometimes getting this to work with libimobiledevice over Wifi. It is rather inconsistent so far and not always connects. I am working hard to figure out why.

set deviceBattery to (do shell script "/usr/local/bin/ideviceinfo -n -u PHONE_UUID -q com.apple.mobile.battery | grep "Capacity" | awk '{print $2}'")

return "iPhone" & return & deviceBattery & "%"

@jrosenkrantz I ended up getting this to work over wifi. You need to cache the last battery value. The wifi connection between devices is not permanent and only happens every now and then (when iTunesSync is looking for the device or when you manually open the device). After testing, I'm pretty sure this is the case with other battery apps as well (including iBetterCharge, Batteries Widget). Also, it seems like wifi connection between devices can only be established on personal networks not enterprise ones.

1 Like

Thanks for that insight. Makes perfect sense!

1 Like