All Projects → Bastl34 → node-yeelight-wifi

Bastl34 / node-yeelight-wifi

Licence: MIT license
node js package for xiaomi yeelight bulbs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-yeelight-wifi

yeelight-cli
a low level, cross-platform command line client for Yeelight
Stars: ✭ 43 (-12.24%)
Mutual labels:  yeelight
yeelight
The nodeJS client library for controlling yeelight over LAN
Stars: ✭ 52 (+6.12%)
Mutual labels:  yeelight
yeelight-hand-controller
With Yeelight Hand Controller you can turn on and off your Yeelight just with a finger snap and change the brightness intensity raising or lowering your hand.
Stars: ✭ 41 (-16.33%)
Mutual labels:  yeelight
python-yeelightbt
Python library for Yeelight's bedside (btle) and candela lamps
Stars: ✭ 77 (+57.14%)
Mutual labels:  yeelight
yeelight.io
Node.js library for controlling Xiao Mi Yeelight
Stars: ✭ 19 (-61.22%)
Mutual labels:  yeelight
hass-miio-yeelink
Xiaomi Miio Yeelink/Yeelight devices for Home Assistant
Stars: ✭ 140 (+185.71%)
Mutual labels:  yeelight
Miio
Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
Stars: ✭ 1,669 (+3306.12%)
Mutual labels:  yeelight
YeelightController
Control your Xiaomi Yeelight from your OSX Device
Stars: ✭ 39 (-20.41%)
Mutual labels:  yeelight
esphome-components
ESPHome components
Stars: ✭ 62 (+26.53%)
Mutual labels:  yeelight
homebridge-yeelight-platform
Homebridge plugin for Yeelight Lights supporting Scenes/Moods/Color Flow/Custom Presets/Music Flow/Night Mode
Stars: ✭ 53 (+8.16%)
Mutual labels:  yeelight
goodbye-mihome
Web UI and plugins to manage Xiaomi MiHome gateway, sensors and smart devices.
Stars: ✭ 92 (+87.76%)
Mutual labels:  yeelight
fluxee
💡 Controlling Yeelight smart lights corresponding to f.lux display color temperature
Stars: ✭ 55 (+12.24%)
Mutual labels:  yeelight
Smart-Lights-Yeelight
Control Yeelight Devices quickly from your Mac OS Tray
Stars: ✭ 51 (+4.08%)
Mutual labels:  yeelight
mi-lamp-re
💡 Reverse Engineering Notes for the Yeelight Bedside Lamp (BLE)
Stars: ✭ 35 (-28.57%)
Mutual labels:  yeelight
esphome-yeelight-ceiling-light
Esphome custom firmware for some Yeelight Ceiling Lights
Stars: ✭ 81 (+65.31%)
Mutual labels:  yeelight

node-yeelight-wifi

"node-yeelight-wifi" is a node.js lib for controlling via wifi connected Yeelights.

It works with the RGBW bulbs, white bulbs and ceiling lights.

You need to activate "Lan control" on your lights. (see Troubleshooting)

Installation

npm install --save node-yeelight-wifi

Howto

Yeelight Lookup

You can lookup for yeelights in your local network like this:

const Lookup = require("node-yeelight-wifi").Lookup;

let look = new Lookup();

look.on("detected",(light) =>
{
    console.log("new yeelight detected: id="+light.id + " name="+light.name);
});

Methods

Once you have a Yeelight (light) object from a lookup you can use it like this:

setPower(power,duration)

Set the power of your Yeelight (on: true, off: false)

light.setPower(true).then(() =>
{
    console.log("success");
}).catch((error =>
{
    console.log("failed",error);
}));

setRGB(rgb,duration)

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);
}));

setHSV(hsv,duration)

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);
}));

setCT(hsv,duration)

Set the color temp value (1700 ~ 6500)

light.setCT(5000).then(() =>
{
    console.log("success");
}).catch((error =>
{
    console.log("failed",error);
}));

setBright(brightness,duration)

Set the color brightness (0-100)

light.setBright(80).then(() =>
{
    console.log("success");
}).catch((error =>
{
    console.log("failed",error);
}));

updateState()

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);
}));

Usable (public) Members of Yeelight-Class (read only)

  • 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})

Events

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); });

Examples

  • see examples/examples.js

Troubleshooting

Licence

Copyright (c) Bastian Karge

MIT (see License.md)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].