BatteryManager

Originally published on June 16, 2016.

Attribute Formatted Value Raw Value
Charging State Unknown Unknown
Charging Time Unknown Unknown seconds
Battery Level Unknown Unknown 0.0–1.0
Discharging Time Unknown Unknown seconds

W3C Battery Status API.
Tested on Firefox 47.0.
Undefined on Edge 13.10586.

Interfaces

Navigator

partial interface Navigator {
    Promise<BatteryManager> getBattery();
};

BatteryManager

interface BatteryManager : EventTarget {
    readonly attribute boolean             charging;
    readonly attribute unrestricted double chargingTime;
    readonly attribute unrestricted double dischargingTime;
    readonly attribute double              level;
             attribute EventHandler        onchargingchange;
             attribute EventHandler        onchargingtimechange;
             attribute EventHandler        ondischargingtimechange;
             attribute EventHandler        onlevelchange;
};

The BatteryManager interface represents the current battery status information of the hosting device.

The charging attribute represents the charging state of the system’s battery.

The chargingTime attribute represents the time remaining in seconds until the system’s battery is fully charged.

The dischargingTime attribute represents the time remaining in seconds until the system’s battery is completely discharged and the system is about to be suspended.

The level attribute represents the level of the system’s battery.

References

Kostiainen, Anssi. “Battery Status API”. W3C Editor’s Draft. World Wide Web Consortium (W3C). June 2, 2016.