"node-yeelight-wifi-extended" is a Node.js lib for controlling via wifi connected Yeelights. This package is a fork of the original node-yeelight-wifi which adds additional methods toi control the bulbs.
It works with the RGBW bulbs, white bulbs and ceiling lights.
You need to activate "Lan control" on your lights. (see Troubleshooting)
npm install --save node-yeelight-wifi-extendedYou can lookup for yeelights in your local network like this:
const Lookup = require("node-yeelight-wifi-extended").Lookup;
let look = new Lookup();
look.on("detected", (light) => {
console.log("new yeelight detected: id=", light.id, "name=", light.name);
});Once you have a Yeelight (light) object from a lookup you can use it like this:
Set the power of your Yeelight (true to turn on, false to turn off)
light.setPower(true).then(() => {
console.log("success");
}).catch((error => {
console.log("failed",error);
}));Set the RGB value (r: 0-255, g: 0-255, b: 0-255)
light.setRGB([255,255,0]).then(() => {
console.log("success");
}).catch((error => {
console.log("failed",error);
}));Set the HSV value (hue: 0-359, sat: 0-100, value/bright=0-100)
light.setHSV([180,70,100]).then(() => {
console.log("success");
}).catch((error => {
console.log("failed",error);
}));Set the color temp value (1700 ~ 6500)
light.setCT(5000).then(() => {
console.log("success");
}).catch((error => {
console.log("failed",error);
}));Set the brightness (1-100)
light.setBright(80).then(() => {
console.log("success");
}).catch((error => {
console.log("failed",error);
}));If you want to request a state (color, bright, power) update
light.updateState().then(() => {
console.log("success");
console.log(light.rgb);
}).catch((error => {
console.log("failed", error);
}));light.power(true/false)light.type("unknown","white","color")light.bright(0-100)light.rgb(example:{r: 0, g: 0, b: 0})light.hsb(example:{h: 0, s: 0, b: 0})
A Yeelight instance has some events:
//socket connect and disconnect events
light.on("connected", () =>{ console.log("connected"); });
light.on("disconnected", () => { console.log("disconnected"); });
//if the color or power state has changed
light.on("stateUpdate", (light) => { console.log(light.rgb); });
//if something went wrong
light.on("failed", (error) => { console.log(error); });- see
examples/examples.js
- Yeelight is not detected?
- enable "LAN Control" on your yeelight
- https://www.yeelight.com/faqs/lan_control
Copyright (c) Bastian Karge
MIT (see License.md)