Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rluvaton/electra-smart-js-client

Electra Smart Javascript Client
https://github.com/rluvaton/electra-smart-js-client

Last synced: 23 days ago
JSON representation

Electra Smart Javascript Client

Awesome Lists containing this project

README

        

# Electra Smart JS client
[![npm](https://img.shields.io/npm/v/electra-smart-js-client?style=plastic)](https://www.npmjs.com/package/electra-smart-js-client)

Port of [`yonatanp/electrasmart`](https://github.com/yonatanp/electrasmart) in JS

## Usage

**Get the authentication data**

```bash
npx electra-smart-js-client

# This will log { "imei": "", "token": "" }
# Save it for later use
```

**Use it from Node.js code**
```js
import { Client } from 'electra-smart-js-client';

async function run() {
const client = await new Client({
imei: '', // This is the imei value from the previous step
token: '', // This is the token value from the previous step
});

const devices = await client.getDevices();

// Choose the device you want to control
const deviceId = devices[0].id;

// Control it 🔥
await client.setMode(deviceId, 'HEAT');
}

run().then(console.log).catch(console.error);

```