This package has been deprecated

Author message:

This package is no longer maintained

node-battery

0.2.2 • Public • Published

Node.js Battery Module

This module provides information on linux and osx about the power sources.

Usage

Node-battery provides two methods:

var nodeBattery = require("node-battery");
 
nodeBattery.getBatteries(function(data){
 
    // Linux only
    // "data" Is an array containing paths to the battery files
});
 
nodeBattery.percentages(function(data){
 
    // "data" Is an array containing a percentage of power left for each battery.
});
 
nodeBattery.isCharging(function(data){
 
    // "data" Is an array containing a 0 or a 1 depending on wheter the battery is being charged.
});

On Linux this module works by reading out the BAT* files in '/sys/class/power_supply'.

If no batteries are detected this could be caused by the fact that your BAT* files start with BAT0 instead of BAT1, to fix this just pass in a 0 as the second argument.

Package Sidebar

Install

npm i node-battery

Weekly Downloads

1

Version

0.2.2

License

MIT

Last publish

Collaborators

  • leonvv