Skip to content

Battery

In this section you will learn how to get battery information - if supported by system:

For function reference and examples we assume, that we imported systeminspector as follows:

const si = require('@ambicuity/systeminspector');

Battery Data

All functions in this section return a promise or can be called with a callback function (parameter cb in the function reference)

FunctionResult objectLinuxBSDMacWinSunComments
si.battery(cb)XXXXbattery information
hasBatteryXXXXindicates presence of battery
cycleCountXXnumbers of recharges
isChargingXXXXindicates if battery is charging
designedCapacityXXXdesigned capacity of battery (mWh)
maxCapacityXXXmax capacity of battery (mWh)
currentCapacityXXXcurrent capacity of battery (mWh)
capacityUnitXXXcapacity unit (mWh if possible)
voltageXXXcurrent voltage of battery (V)
percentXXXXcharging level in percent
timeRemainingXXminutes left (if discharging)
acConnectedXXXXAC connected
typeXXbattery type
modelXXmodel
manufacturerXXmanufacturer
serialXXbattery serial
additionalBatteries\Xarray of additional batteries

Known issues

Windows Battery

Windows battery data comes from PowerShell CIM/WMI providers and sometimes needs administrator privileges. If you still do not get values, your system or firmware might not support this feature.

Examples

Example
const si = require('@ambicuity/systeminspector');
si.battery().then(data => console.log(data));
json
{
  hasBattery: true,
  cycleCount: 35,
  isCharging: false,
  designedCapacity: 64958,
  maxCapacity: 65865,
  currentCapacity: 64856,
  voltage: 12.767,
  capacityUnit: 'mWh',
  percent: 100,
  timeRemaining: 551,
  acConnected: false,
  type: 'Li-ion',
  model: '',
  manufacturer: 'Apple',
  serial: 'F9Y19860Y9AH9XBAX'
}
Inspector AI
SystemInspector AI initialized. How can I help you query your hardware?