diff --git a/CHANGELOG.md b/CHANGELOG.md index 042886c..8b3974a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.20.0 | 2020-01-25 | `battery()` added designcapacity, voltage, unit | | 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors | | 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS | | 4.19.2 | 2020-01-19 | `cpu()` muli-processor fix windows | diff --git a/README.md b/README.md index 94b7987..6b6233c 100644 --- a/README.md +++ b/README.md @@ -29,20 +29,6 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -#### Happy new year - -``` - .''. - .''. . *''* :_\/_: . - :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. - .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- - :_\/_:'.:::. ' *''* * '.\'/.' _\(/_'.':'.' - : /\ : ::::: *_\/_* -= o =- /)\ ' * - '..' ':::' * /\ * .'/.\'. ' - * *..* : - * -``` - This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 1 mio downloads per month, > 4 mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 @@ -98,13 +84,13 @@ si.cpu() (last 7 major and minor version releases) +- Version 4.20.0: `battery()` added designcapacity, voltage, unit - Version 4.19.0: `osInfo()` added uefi (OS uses UEFI during startup) - Version 4.18.0: `networkInterfaces()` added dhcp for mac os, added dhcp linux fallback - Version 4.17.0: `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState - Version 4.16.0: `networkGatewayDefault()` added - Version 4.15.0: `cpu()` added governor (linux) - Version 4.14.0: `processes()` added process path and params -- Version 4.13.0: `networkConnections()` added PID, process - ... You can find all changes here: [detailed changelog][changelog-url] @@ -246,8 +232,11 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | hasbattery | X | X | X | X | | indicates presence of battery | | | cyclecount | X | | X | | | numbers of recharges | | | ischarging | X | X | X | X | | indicates if battery is charging | -| | maxcapacity | X | | X | X | | max capacity of battery | -| | currentcapacity | X | | X | X | | current capacity of battery | +| | designedcapacity | X | | X | X | | max capacity of battery (mWh) | +| | maxcapacity | X | | X | X | | max capacity of battery (mWh) | +| | currentcapacity | X | | X | X | | current capacity of battery (mWh) | +| | capacityUnit | X | | X | X | | capacity unit (mWh) | +| | voltage | X | | X | X | | current voltage of battery (V) | | | percent | X | X | X | X | | charging level in percent | | | timeremaining | X | | X | | | minutes left (if discharging) | | | acconnected | X | X | X | X | | AC connected | diff --git a/docs/battery.html b/docs/battery.html index e73507f..486a3d7 100644 --- a/docs/battery.html +++ b/docs/battery.html @@ -105,6 +105,16 @@ indicates if battery is charging + + + designedcapacity + X + + X + X + + designed capacity of battery (mWh) + maxcapacity @@ -113,7 +123,7 @@ X X - max capacity of battery + max capacity of battery (mWh) @@ -123,7 +133,27 @@ X X - current capacity of battery + current capacity of battery (mWh) + + + + capacityUnit + X + + X + X + + capacity unit (mWh) + + + + voltage + X + + X + X + + current voltage of battery (V) diff --git a/docs/history.html b/docs/history.html index 1028130..a9cd9bf 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.20.0 + 2020-01-25 + battery() added designcapacity, voltage, unit + 4.19.4 2020-01-24 diff --git a/docs/index.html b/docs/index.html index 29de977..be793da 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.19.4
+
Current Version: 4.20.0
@@ -206,7 +206,7 @@
Downloads last month
-
236
+
239
Dependends
diff --git a/lib/battery.js b/lib/battery.js index 447bc68..c9e07cd 100644 --- a/lib/battery.js +++ b/lib/battery.js @@ -35,8 +35,11 @@ module.exports = function (callback) { hasbattery: false, cyclecount: 0, ischarging: false, + designedcapacity: 0, maxcapacity: 0, currentcapacity: 0, + voltage: 0, + capacityUnit: '', percent: 0, timeremaining: -1, acconnected: true, @@ -60,14 +63,16 @@ module.exports = function (callback) { result.ischarging = (util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging'); result.acconnected = result.ischarging; + result.voltage = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_VOLTAGE_NOW', '='), 10) / 1000000.0; result.cyclecount = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CYCLE_COUNT', '='), 10); - result.maxcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL', '='), 10); + result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL', '='), 10) / 1000.0 / (result.voltage || 1) * 100) / 100; + result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL_DESIGN', '='), 10) / 1000.0 / (result.voltage || 1) * 100) / 100| result.maxcapacity; + result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1) * 100) / 100; + result.capacityUnit = 'mWh'; if (!result.maxcapacity) { - result.maxcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10); - } - result.currentcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10); - if (!result.currentcapacity) { - result.currentcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10); + result.maxcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0; + result.designcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL_DESIGN', '='), 10) / 1000.0 | result.maxcapacity; + result.currentcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10) / 1000.0; } const percent = util.getValue(lines, 'POWER_SUPPLY_CAPACITY', '='); const energy = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10); @@ -113,6 +118,7 @@ module.exports = function (callback) { result.acconnected = result.ischarging; result.maxcapacity = -1; result.currentcapacity = -1; + result.capacityUnit = 'unknown'; result.percent = batteries ? percent : -1; if (callback) { callback(result); } resolve(result); @@ -120,12 +126,15 @@ module.exports = function (callback) { } if (_darwin) { - exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|MaxCapacity|CurrentCapacity|BatterySerialNumber|TimeRemaining"; pmset -g batt | grep %', function (error, stdout) { + exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|BatterySerialNumber|TimeRemaining|Voltage"; pmset -g batt | grep %', function (error, stdout) { if (stdout) { let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n'); result.cyclecount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10); - result.maxcapacity = parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10); - result.currentcapacity = parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10); + result.capacityUnit = 'mWh'; + result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0; + result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10) * (result.voltage || 1) * 100) / 100; + result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10) * (result.voltage || 1) * 100) / 100; + result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1) * 100) / 100; result.manufacturer = 'Apple'; result.serial = util.getValue(lines, 'BatterySerialNumber', '='); let percent = -1; @@ -163,7 +172,7 @@ module.exports = function (callback) { } if (_windows) { try { - util.wmic('Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value').then((stdout) => { + util.wmic('Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining, DesignVoltage, FullChargeCapacity /value').then((stdout) => { if (stdout) { let lines = stdout.split('\r\n'); let status = util.getValue(lines, 'BatteryStatus', '=').trim(); @@ -182,6 +191,9 @@ module.exports = function (callback) { const statusValue = parseInt(status); result.hasbattery = true; result.maxcapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0); + result.designcapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0); + result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0; + result.capacityUnit = 'mWh'; result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0); result.currentcapacity = parseInt(result.maxcapacity * result.percent / 100); result.ischarging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100); diff --git a/lib/index.d.ts b/lib/index.d.ts index f06d208..15fe936 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -146,8 +146,11 @@ export namespace Systeminformation { hasbattery: boolean; cyclecount: number; ischarging: boolean; + voltage: number; + designedcapacity: number; maxcapacity: number; currentcapacity: number; + capacityUnit: string; percent: number; timeremaining: number, acconnected: boolean;