1.0.6 • Published 6 years ago

node-yeelight v1.0.6

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

node-yeelight

This package lets you control Xiaomi Yeelight WiFi enabled smart light bulbs.

Features

  • Discover and connect to smart light bulbs
  • Turn smart light bulbs on and off

Supported Devices

This library has only been tested on the following device:

There is no reason why it shouldn't work with the RGB version of Yeelight - let me know your mileage.

Usage

Installation

Install using npm: npm i --save node-yeelight

Discovering Devices

var Yeelight = require('node-yeelight');
var y = new Yeelight;

y.on('ready', function() {
	y.discover(); // scan network for active Yeelights
});

y.listen();

Connecting To Devices

// listen for device added event
y.on('deviceadded', function(device) {
  y.connect(device); // attempt to connect
});

Controlling Devices

Before attempting to control any devices you must have completed device discovery and connection.

y.on('deviceconnected', function(device) {

  // turn Yeelight on/off
  y.setPower(
    device, // device object
    true, // device state (true/false)
    300 // transition speed in ms
  );
  
  // set Yeelight brightness
  y.setBrightness(
    device, // device object
    50, // brightness percentage (1-100)
    300 // transition speed in ms
  );
  
});

Licence

(The MIT License)

Copyright (c) 2016 James Blanksby james@blanks.by

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.