Like everyone, we are in a transition from laptops that use Magsafe 2 to Thunderbolt3/USB-C. Is there an easy way to reliably query machines charger type in inventory? Ideally setting it as an Extension Attribute under Hardware.
I want this because I have several hundred desks on several floors that use one of two setups (USB-A/Magsafe vs USB-C). If someone is moving desks I need to check what their machine needs vs what the current occupant's machine needs.
I am wondering if just pulling USB30Bus vs USB31Bus from system_profiler is good enough. I never thought this possible, but I may have stumbled upon the single upside to the absolutist switch from 3.0 to 3.1... Besides Mac Minis, are there any Mac's that have both USB-C and USB-A? Does anything use USB 3.1 over USB-A?
As an aside, does anyone have example scripts of pulling from system_profiler using json/jq?
That seems to return the name of the battery. As part of SPPowerDateType there is: AC Charger Information:
Connected: Yes ID: 0x0aa1 Wattage (W): 85 Family: 0x0085 Serial Number: 0x00e25313 Charging: No
But I'm not sure how to interpret what Family means. Also like degreening said it only appears when it is actually connected to a charger.
I think maybe checking Thunderbolt type is sort of a way to go. I don't think anything has TB3 and a MagSafe. But I'm not sure how to actually find that either. But I can find its speed which is sort of correct. I don't think anything does 40 Gb/s and also has 20 Gb/s ports.
system_profiler SPThunderboltDataType | grep -m 1 Speed: | cut -c 24-26
I'll keep looking for a cleaner way to do this. If anyone comes up with a better idea let me know.
>>> import subprocess >>> import plistlib >>> >>> cmd = ['system_profiler', 'SPPowerDataType', '-xml'] >>> proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) >>> out, err = proc.communicate() >>> data = plistlib.readPlistFromString(out) >>> print data['_items']['sppower_ac_charger_name'] 87W USB-C Power Adapter
There is a python example of parsing plist output data from