# chargemaster

> control various LiIon/NiMH/... chargers with nodejs

Latest version **0.1.4** (published 2016-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install chargemaster
pnpm add chargemaster
yarn add chargemaster
bun add chargemaster
```

Provides the command `chargemaster`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2016-09-21 |
| First published | 2016-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Andreas Langecker |
| Maintainers | alangecker |

## Links

- npm: https://www.npmjs.com/package/chargemaster
- Repository: https://github.com/alangecker/chargemaster
- Homepage: https://github.com/alangecker/chargemaster#readme
- Issues: https://github.com/alangecker/chargemaster/issues
- npm.io page: https://npm.io/package/chargemaster

## Dependencies (6)

- [colors](https://npm.io/package/colors.md) ^1.1.2
- [node-hid](https://npm.io/package/node-hid.md) ^0.5.1
- [babel-register](https://npm.io/package/babel-register.md) ^6.14.0
- [command-line-args](https://npm.io/package/command-line-args.md) ^3.0.1
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^3.0.3
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.14.0

## Recent versions

- 0.1.4 (latest) — 2016-09-21
- 0.1.3 — 2016-09-20
- 0.1.2 — 2016-09-20
- 0.1.1 — 2016-09-19
- 0.1.0 — 2016-09-18

## README

# chargemaster #
Control various SkyRC, Voltcraft,.. battery charger with javascript/nodejs


#### What works
  - charging
  - discharging
  - status info
  - read device info

#### What does not work
  - change programs
  - change system options
  - update firmeware

#### Tested devices
  - Voltcraft Ultimate 1000W


## Warning!
very early version! Bugs can inflame your batteries! Use at your own risk! Neither me or other contributors will take responsibility for damages.


## Usage as CLI Tool
```bash
# install
$ npm install -g chargemaster

# help
$ chargemaster --help

# example
$ sudo chargemaster --type LiIon --mode charge --cells 7 --current 0.5


```
## Usage as npm module
```
$ npm install chargemaster
```
```js
var ChargeMaster = require('chargemaster');
```
## API



#### new ChargeMaster(vendorId, deviceId)
  connects to Charger over USB. You can get the vendorId and deviceId with ```$ lsusb```
  ```js
  var cm = new ChargeMaster(0x0000, 0x0001);
  ```

#### cm.getStatus()
gets current status as ChargeInfo instance

###### Example Response
  ```js
    ChargeInfo {
      workState: 1,
      errorCode: 0,
      OutVoltage: 4008, // mV
      Current: 0, // mA
      ChargeTimer: 4, // s
      ChargeMah: 0, // mAh
      ExtTemp: 0,
      IntTemp: 22,
      Intimpedance: 0,
      CELL1: 6,
      CELL2: 5,
      CELL3: 5,
      CELL4: 6,
      CELL5: 5,
      CELL6: 5,
      CELL7: 5,
      CELL8: 5
}
  ```
#### cm.setBattType(string type)
Possible types: ```LiPo, LiIon, LiFe, LiHv, NiMH, NiCd, Pb```

#### cm.charge(Object options) ```Promise```
starts charging. Pass options as an Object
###### Options
```js
{
    cells: 1, // number of cells in series
    current: 0.1, // in A
    cellVoltage: 3.1, // in V
    endVoltage: 4.2 // in V
}
```

#### cm.discharge(Object options) ```Promise```
starts discharging
###### Options
```js
{
    cells: 1, // number of cells in series
    current: 0.1, // in A
    cellVoltage: 3.1 // in V
}
```
#### cm.stop(Object options) ```Promise```
starts discharging

####  cm.getMachineInfo() ```Promise```
  gets details about the charger
###### Example Response
```js
{
    machineId: '100069',
    coreType: '',
    upgradeType: 1,
    isEncrypted: false,
    customerId: 4,
    languageId: 0,
    softwareVersion: 1.06,
    hardwareVersion: 1,
    reserved: 0,
    mctype: 0,
    checksum: 195
}
```

#### cm.discharge(Object options) ```Promise```
starts discharging.


#### Event: "connected"
#### Event: "status"
- ```info``` object with a lot of status informations

#### Event: "started"
#### Event: "stopped"
#### Event: "finish"
#### Event: "error"
- ```error``` the error object


## Example
```js
const ChargeMaster = require('chargemaster');

const cm = new ChargeMaster(0x0000, 0x0001);

cm.on('error', (err) => {
  console.log('Error:', err);
});

cm.getMachineInfo().then( (info) => {
  console.log(`MachineId: ${info.machineId}\nFirmware: ${info.softwareVersion}`);
});

cm.setBattType('LiIon');

cm.charge({
  cells: 1,
  current: 1.0 // A
});
```

## License
####The MIT License (MIT)
Copyright (c) 2016 Andreas Langecker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/chargemaster · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
