Yeelight library for Node.js

Hi all, I’ve create a NPM package for controlling Yeelight bulb base on the spec. Hope it helps. Suggestions and PRs are welcome. Cheers.

More detail can be found in link.

yeelight.io

Description

yeelight.io is a simple library for you to control YeeLight LED bulb through LAN.

Installation

npm install yeelight.io

Usage

Using Bulb type

'use strict';

const { Bulb } = require('yeelight.io');

const l1 = new Bulb('192.168.1.227');

l1.on('connected', (light) => {
  console.log(`connected to ${light.ip}`);
  light.toggle();
  light.disconnect();
});

l1.on('disconnected', (light) => {
  console.log(`disconnected with ${light.ip}`);
});

l1.on('error', (light, err) => {
  console.error(`error [${err.message}] occur on ${light.ip}`);
  light.disconnect();

});

l1.connect();

Using pre-implement methods

'use strict';

const { toggle } = require('yeelight.io');

toggle('192.168.1.227', (err) => {
  if (err) {
    console.error(`error [${err.message}] occured on 192.168.10.227`);
  } else {
    console.log('toggle 192.168.1.227 success');
  }
});

License

MIT

You are so so so great.