GithubHelp home page GithubHelp logo

song940 / node-yeelight Goto Github PK

View Code? Open in Web Editor NEW
87.0 7.0 20.0 63 KB

:bulb: A Node.js Library for the Yeelight smart bulb

Home Page: https://npmjs.org/yeelight2

License: MIT License

JavaScript 100.00%
yeelight bulb hardware ssdp iot-application iot

node-yeelight's Introduction

Yeelight Yeelight2

A Node.js lib for the yeelight bulb

Installation

$ npm i yeelight2 --save

Simple example

const Yeelight = require('yeelight2');

(async () => { 
  const light = await Yeelight.find();
  console.log(light.name);
  light.toggle();
})();

Discover all devices in the network.

const Yeelight = require('yeelight2');

Yeelight.discover(function(light){

  console.log(light.name);

  function blink(){
    light.toggle();
  }

  setInterval(blink, 2000);

  // `Yeelight.discover` can discover multiple devices untill the ssdp close.
  // So you need to close it manually. DO NOT FORGET IT.
  // Here is an example to close it after find the first device.
  // const discover = this;
  // discover.close(); // stop searching
});

Here is an example to close it after 10 seconds.

const discover = Yeelight.discover(light => {
  console.log(light.name);
});

setTimeout(() => {
  discover.close(); // stop searching
}, 10000);

For a complete example look at <example/index.js> .

Debug

NODE_DEBUG=yeelight

Then start your app.

Documentation

see https://lsong.org/node-yeelight

Contributing

  • Fork this Repo first
  • Clone your Repo
  • Install dependencies by $ npm install
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Publish your local branch, Open a pull request
  • Enjoy hacking <3

Golang Implementation

Golang API for Yeelight

https://github.com/song940/yeelight-go

MIT

Copyright (c) 2016 Lsong <[email protected]>

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.


node-yeelight's People

Contributors

jnullj avatar jpg06 avatar shuunen avatar song940 avatar zeckson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-yeelight's Issues

Yeelight use set_scene

This using the library in node, and I see that to use set_scene is necessary to put ["ct",6500,50] for example, and in the function appears (type, val, val2, val3), as I do to pass that from node-network?

If I change (type, val, val2, val3) to (test) and pass a json with ["ct",6500,50] it works fine.

Should we edit it?

name seems to allways be empty

I am writing a small gui for controling yeelight from the desktop.
i get empty name for my rgb celling lamp
i used the code from the example to get the name using get_prop('name')
and i get name with empty string.
my console.log(device) after discover also shows empty name
image
i named the lamp using the yeelight app but this did not help

Error: read ECONNRESET not handled with .catch()

Hello,

I use:
nodejs 15.12.0
node-red 1.2.9
node-red-contrib-yeelight 1.0.7

I got this error after a while:

28 Mar 17:13:42 - [error] [yeelight-config:5f497ad3.1fd3a4] Error: read ECONNRESET
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Network timeout, Yeelight not response
at Timeout._onTimeout (/root/.node-red/node_modules/yeelight2/index.js:230:29)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)

Can you check?
Thank you

Error : client quota exceeded

Hi,

First of all thank you for this plugin. It's really helpful.
I'm designing a smart home server on a raspberry pi 3 and currently have a yeelight RGB bulb.

It appears that, when I'm sending to much request to the bulb, I get an error "client quota exceeded" but I'm unable to find any informations about that error.

Any help would be appreciated.

Unhandled promise rejection: timeout/[object Object]

This issue happens after changing colors of the Yeelight (I guess it's E27, RGB definitely) Lightbulb too fast.

(node:13721) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
(node:13721) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

After adding set DEBUG=yeelight to CLI parameters:

Error: timeout
    at Timeout._onTimeout (/home/unm4sk/Desktop/homeserver-dev/node_modules/yeelight2/index.js:167:16)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)

This sometimes causes the Yeelight Lightbulb itself to freeze, so it's not discoverable anymore until I turn it off and on again (in this case unscrew/screw). Can anything be done about this?

Error with version 1.3.7 and Celling light

Hi,
I have an error message with the last version 1.3.7.
I have test on two installations and a have the same result with Yeelight Celling light (it's ok with Bulb).
The error message is:
_UnhandledPromiseRejectionWarning: Error: Network timeout, Yeelight not response
at Timeout.onTimeout (/home/nodered/jpgDomotique/node-red-contrib-yeelight-compat-hue/node_modules/yeelight2/index.js:231:29)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)

I get this error for each celling light.

I made some tests and i found that if i comment two "props" in index.js (for example "flowing" and "flow_params" in Yeelight.prototype.props=[...] ), all is working like in older version.
The props values commented is not important: it is the number of props which is important.

Can you make a correction to solve the problem ?

Yeelight color4 Return unparsable error message when calling get_prop

I was trying to connect to my yeelight color4 using node-red. But it seems like if the "active_mode" property is present in the params array for get_prop then the bulp return an unparsable error message: {"id":, "error":{"code":-1, "message":"invalid command"}}. It might be a yeelight issue but maybe something can be done to alliviate this problem, Such that syncing the bulp will not crash the application? everything works if i comment out "active_mode" in the prop array at index.js line 163.

Response confirmation

Hello,
I've noticed taht there is no response handler after sending a command. The code just ASSUME that the command was accepted. Maybe we could add a listener to keep the state updated based on a actual response.

Node red crashing....... NPM Version not updated?

I have recently reinstalled node red and for some reason I have been noticing various yeelight crashing with the error below

Jan  9 10:16:48 pi Node-RED[12998]: Error: Network timeout, Yeelight not response
Jan  9 10:16:48 pi Node-RED[12998]:     at Timeout._onTimeout (/home/pi/.node-red/node_modules/yeelight2/index.js:230:29)
Jan  9 10:16:48 pi Node-RED[12998]:     at listOnTimeout (node:internal/timers:559:17)
Jan  9 10:16:48 pi Node-RED[12998]:     at processTimers (node:internal/timers:502:7)

Any ideas what it could be?

Thanks

Yeelight RGBW E27 name prop

I have given the bulb a name in the yeelight app. It still shows its factory hostname in my router too. When i discover the light with node-yeelight the name prop is empty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.