# scinpower-battery-subscribe

> Subscribe to the data content reported by the battery from Zhixiang Cloud

Latest version **1.0.4** (published 2023-11-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install scinpower-battery-subscribe
pnpm add scinpower-battery-subscribe
yarn add scinpower-battery-subscribe
bun add scinpower-battery-subscribe
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-11-24 |
| First published | 2023-11-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | seven |
| Maintainers | seven_step |

## Links

- npm: https://www.npmjs.com/package/scinpower-battery-subscribe
- npm.io page: https://npm.io/package/scinpower-battery-subscribe

## Dependencies (11)

- [yn](https://npm.io/package/yn.md) ^3.1.1
- [arg](https://npm.io/package/arg.md) ^4.1.3
- [diff](https://npm.io/package/diff.md) ^4.0.2
- [acorn](https://npm.io/package/acorn.md) ^8.11.2
- [acorn-walk](https://npm.io/package/acorn-walk.md) ^8.3.0
- [make-error](https://npm.io/package/make-error.md) ^1.3.6
- [typescript](https://npm.io/package/typescript.md) ^5.3.2
- [undici-types](https://npm.io/package/undici-types.md) ^5.26.5
- [create-require](https://npm.io/package/create-require.md) ^1.1.1
- [v8-compile-cache-lib](https://npm.io/package/v8-compile-cache-lib.md) ^3.0.1
- [scinpower-core-subscribe](https://npm.io/package/scinpower-core-subscribe.md) ^1.0.5

## Recent versions

- 1.0.4 (latest) — 2023-11-24
- 1.0.3 — 2023-11-24
- 1.0.2 — 2023-11-23
- 1.0.1 — 2023-11-23
- 1.0.0 — 2023-11-23

## README

#### Install
```shell
npm install scinpower-battery-subscribe
```

#### TypeScript
```typescript
import * as b from "scinpower-battery-subscribe";

const key = "key"
const secret = "secret"
const topics = ["parse.report.key","parse.warn.key","rsp.status.key","parse.gps.key"]
const client = new b.BatteryClient(key, secret)

client.subscribe(topics,1, async (message: b.Message, data: any) => {
  if (data === undefined) {
    throw new Error("Unknown data type")
  }
  if (data instanceof b.StatusData) {}
  if (data instanceof b.BatteryLoginData) {}
  if (data instanceof b.GpsData) {}
  if (data instanceof b.BmsData) {}
  if (data instanceof b.SensorShockData) {}
  if (data instanceof b.ModelIOData) {}
  if (data instanceof b.BmsIdData) {}
  if (data instanceof b.BmsWarnData) {}
}).then()
```

#### NodeJs
```javascript
const b = require("scinpower-battery-subscribe")

const key = "key"
const secret = "secret"
const topics = ["parse.report.key","parse.warn.key","rsp.status.key","parse.gps.key"]
const client = new b.BatteryClient(key, secret)

client.subscribe(topics,1, async (message, data) => {
  if (data === undefined) {
    throw new Error("Unknown data type")
  }
  if (data instanceof b.StatusData) {}
  if (data instanceof b.BatteryLoginData) {}
  if (data instanceof b.GpsData) {}
  if (data instanceof b.BmsData) {}
  if (data instanceof b.SensorShockData) {}
  if (data instanceof b.ModelIOData) {}
  if (data instanceof b.BmsIdData) {}
  if (data instanceof b.BmsWarnData) {}

}).then()
```

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