Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yeelight causing node-red to crash #4

Open
waqaslam opened this issue Dec 7, 2017 · 25 comments
Open

Yeelight causing node-red to crash #4

waqaslam opened this issue Dec 7, 2017 · 25 comments

Comments

@waqaslam
Copy link

waqaslam commented Dec 7, 2017

Hi
Thanks for a convenient node to control yeelight.
Seems like the node is not handling connection errors properly and causing node-red to crash.

Dec 07 10:18:22 home-server systemd[1]: Started Node-RED.
Dec 07 10:18:25 home-server node-red[4821]: 7 Dec 10:18:25 - [info]
Dec 07 10:18:25 home-server node-red[4821]: Welcome to Node-RED
Dec 07 10:18:25 home-server node-red[4821]: ===================
Dec 07 10:18:25 home-server node-red[4821]: 7 Dec 10:18:25 - [info] Node-RED version: v0.17.5
Dec 07 10:18:25 home-server node-red[4821]: 7 Dec 10:18:25 - [info] Node.js  version: v6.12.1
Dec 07 10:18:25 home-server node-red[4821]: 7 Dec 10:18:25 - [info] Linux 4.10.0-38-generic ia32 LE
Dec 07 10:18:26 home-server node-red[4821]: 7 Dec 10:18:26 - [info] Loading palette nodes
Dec 07 10:18:30 home-server node-red[4821]: 7 Dec 10:18:30 - [info] Dashboard version 2.6.2 started at /ui
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [warn] ------------------------------------------------------
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [warn] ------------------------------------------------------
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [info] Settings file  : /home/waqas/.node-red/settings.js
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [info] User directory : /home/waqas/.node-red
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [info] Flows file     : /home/waqas/.node-red/flows_home-server.json
Dec 07 10:18:31 home-server node-red[4821]: 7 Dec 10:18:31 - [info] Server now running at http://127.0.0.1:1880/
Dec 07 10:18:32 home-server node-red[4821]: 7 Dec 10:18:32 - [info] Starting flows
Dec 07 10:18:33 home-server node-red[4821]: 7 Dec 10:18:33 - [info] Started flows
Dec 07 10:18:33 home-server node-red[4821]: 7 Dec 10:18:33 - [info] [mqtt-broker:e22c4cec.afe0c] Connected to broker: mqtt://localhost:1883
Dec 07 10:18:34 home-server node-red[4821]: Ignoring qBittorrent download-complete routine due to payload timeout
Dec 07 10:18:36 home-server node-red[4821]: 7 Dec 10:18:36 - [red] Uncaught Exception:
Dec 07 10:18:36 home-server node-red[4821]: 7 Dec 10:18:36 - Error: connect EHOSTUNREACH 172.16.0.5:55443
Dec 07 10:18:36 home-server node-red[4821]:     at Object.exports._errnoException (util.js:1020:11)
Dec 07 10:18:36 home-server node-red[4821]:     at exports._exceptionWithHostPort (util.js:1043:20)
Dec 07 10:18:36 home-server node-red[4821]:     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
Dec 07 10:18:36 home-server systemd[1]: node-red.service: Main process exited, code=exited, status=1/FAILURE
Dec 07 10:18:36 home-server systemd[1]: node-red.service: Unit entered failed state.
Dec 07 10:18:36 home-server systemd[1]: node-red.service: Failed with result 'exit-code'.
Dec 07 10:18:37 home-server systemd[1]: node-red.service: Service hold-off time over, scheduling restart.
Dec 07 10:18:37 home-server systemd[1]: Stopped Node-RED.
Dec 07 10:18:37 home-server systemd[1]: Started Node-RED.

Once I removed yeelight, everything worked fine.
The problem can be seen below where it fails to connect yeelight bulb on the given IP address:

Dec 07 10:18:36 home-server node-red[4821]: 7 Dec 10:18:36 - Error: connect EHOSTUNREACH 172.16.0.5:55443
Dec 07 10:18:36 home-server node-red[4821]:     at Object.exports._errnoException (util.js:1020:11)
Dec 07 10:18:36 home-server node-red[4821]:     at exports._exceptionWithHostPort (util.js:1043:20)
Dec 07 10:18:36 home-server node-red[4821]:     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)

I also posted it on node-red pages assuming that it was a bug with it- but it's not.

Is there a future release planned to address this issue?
regards

-Waqas

@Gromina
Copy link
Owner

Gromina commented Dec 13, 2017

Could you please test 1.0.4 version in several cases:

  • starting node-red when yeelight is offline
  • starting node-res when yeelight is online
  • turning yeelight offline when node-red is running

I can't test it on hardware tight now :(

@BugsonPL
Copy link

BugsonPL commented Apr 2, 2019

Having the same issue with crashing the node red.

The problem is present when bulb is offline- so it should be easy to reproduce.

Marcin

@timonsku
Copy link
Collaborator

timonsku commented Apr 2, 2019

@BugsonPL
I made a few fixes yesterday, was actually a new issue. If you install the node from git it should at least not crash anymore when the light goes offline and it tries to re-connect.

@Gromina
Copy link
Owner

Gromina commented Apr 8, 2019

@PTS93 shall I bump and upload newer package to npmjs?

@timonsku
Copy link
Collaborator

timonsku commented Apr 8, 2019

@Gromina ah yes that'd be great

@BugsonPL
Copy link

Still not stable:

_> May 17 08:11:23 openHABianPi Node-RED[9142]: Yeelight error { Error: read ECONNRESET
May 17 08:11:23 openHABianPi Node-RED[9142]: at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
May 17 08:11:23 openHABianPi Node-RED[9142]: 17 May 08:11:23 - [red] Uncaught Exception:
May 17 08:11:23 openHABianPi Node-RED[9142]: 17 May 08:11:23 - TypeError: this.error is not a function
May 17 08:11:23 openHABianPi Node-RED[9142]: at Yeelight. (/home/openhabian/.node-red/node_modules/node-red-contrib-yeelight/yeelight/yeelight.js:36:22)
May 17 08:11:23 openHABianPi Node-RED[9142]: at Yeelight.emit (events.js:189:13)
May 17 08:11:23 openHABianPi Node-RED[9142]: at Yeelight. (/home/openhabian/.node-red/node_modules/yeelight2/index.js:45:10)
May 17 08:11:23 openHABianPi Node-RED[9142]: at Socket.emit (events.js:189:13)
May 17 08:11:23 openHABianPi Node-RED[9142]: at emitErrorNT (internal/streams/destroy.js:82:8)
May 17 08:11:23 openHABianPi Node-RED[9142]: at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
May 17 08:11:23 openHABianPi Node-RED[9142]: at process._tickCallback (internal/process/next_tick.js:63:19)
May 17 08:11:23 openHABianPi systemd[1]: Stopped Node-RED graphical event wiring tool.
May 17 08:11:23 openHABianPi systemd[1]: Started Node-RED graphical event wiring tool.

@grumpazoid
Copy link

grumpazoid commented Dec 8, 2019

Same problem here - December 2019.
I had just updated a few nodes so needed to reboot. Panic set in as node red just kept rebooting. I upgraded node red to latest version (1.0.3) and tried again. Issuing the node-red-start command showed the Yeelight node failing because my yeelight was not online. Put the lamp online and node red starts without failure.
Have uninstalled yeelight node and all is well again.

@BorisHruby
Copy link

I have the same problem. The node works well if the light is on. If it is not on the network node-red crashes. Could you please look into it? I'd reall yappreciate it. Thanks a lot in advance. Have a nice day.

@waqaslam
Copy link
Author

waqaslam commented Feb 6, 2020

Just so you all know, I used this node to connect to my yeelights but since it's still buggy, so I moved to creating my own solution. It's pretty simple and not that difficult to do a custom solution by listening to bulb's broadcast messages to identify them in the network and start sending commands.

@murraybrandon
Copy link

+1 for this issue, as it is happening to me at the moment.

If the yeelight bulb is switched off or just offline for some reason Node Red continually reboots and you can't log in to fix the problem before it reboots (if you are not at home to switch the bub back on). Node Red reboots without running the yeelight node, it's on initialisation of the yeelight node, which I presume tries to create a connection to the bulb.

I do not know Javascript, but it looks like you need to add a try/catch in the setupConnection function as well, and if that fails to be set up, retry from time to time to set it up again (at least handle the case where yeelight is off).

@murraybrandon
Copy link

Just so you all know, I used this node to connect to my yeelights but since it's still buggy, so I moved to creating my own solution. It's pretty simple and not that difficult to do a custom solution by listening to bulb's broadcast messages to identify them in the network and start sending commands.

Would you consider posting your node configuration to control it?

@murraybrandon
Copy link

murraybrandon commented Mar 14, 2020

Ok, so my workaround was to use a TCPIP client to do the same thing as the yeelight nodes. The problem is I couldn't find a version of the yeelight node that stays working or that doesn't cause the service to reboot all the time. If this is a problem for you, try this node red code:
(deleted example, as it wasn't formatted properly - I will try again below)

@grumpazoid
Copy link

@murray Thanks for posting your code. I am getting unexpected token error when I try to import.

I am currently using node-red-contrib-yeelight-compat-hue which is doing the job so far.

@murraybrandon
Copy link

[{"id":"9327255d.b45df8","type":"link in","z":"be91a2e4.eacc","name":"Study Yeelight Flash Once","links":["6bb3ce7f.4667e","709ac222.19dafc","84468ab2.49b2a8","bbbdda39.404ef8","42f583af.2dc67c","f0c02bf1.1ac438"],"x":255,"y":460,"wires":[["3f512e4a.ab11e2","29f4c4c7.3a53cc"]]},{"id":"3f512e4a.ab11e2","type":"delay","z":"be91a2e4.eacc","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":480,"wires":[["75f9d6ce.449b08"]]},{"id":"9605eb5b.64fa88","type":"inject","z":"be91a2e4.eacc","name":"Red","topic":"","payload":"ff0000","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":420,"wires":[["709ac222.19dafc"]]},{"id":"709ac222.19dafc","type":"link out","z":"be91a2e4.eacc","name":"","links":["9327255d.b45df8"],"x":175,"y":420,"wires":[]},{"id":"54ea52c.bf73fac","type":"link in","z":"be91a2e4.eacc","name":"Study Yeelight Flash 3 times","links":["47ab4d.8f1e24b4","48f9f8a6.53c8a8","9b6db556.12e958","c1c448de.0b7a28"],"x":255,"y":540,"wires":[["43914252.acf10c","ebcf8d61.2cae1","29f4c4c7.3a53cc","42f583af.2dc67c"]]},{"id":"43914252.acf10c","type":"delay","z":"be91a2e4.eacc","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":580,"wires":[["42f583af.2dc67c"]]},{"id":"ebcf8d61.2cae1","type":"delay","z":"be91a2e4.eacc","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":620,"wires":[["42f583af.2dc67c"]]},{"id":"eae14c93.e2d4b","type":"link in","z":"be91a2e4.eacc","name":"Study Yeelight RGB ON - 0xaabbcc String in payload","links":[],"x":255,"y":400,"wires":[["29f4c4c7.3a53cc"]]},{"id":"35b6edb8.1a01e2","type":"inject","z":"be91a2e4.eacc","name":"Green","topic":"","payload":"00ff00","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":460,"wires":[["6bb3ce7f.4667e"]]},{"id":"6bb3ce7f.4667e","type":"link out","z":"be91a2e4.eacc","name":"","links":["9327255d.b45df8"],"x":175,"y":460,"wires":[]},{"id":"3fd77b37.5ab414","type":"inject","z":"be91a2e4.eacc","name":"Blue","topic":"","payload":"0000FF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":500,"wires":[["bbbdda39.404ef8"]]},{"id":"bbbdda39.404ef8","type":"link out","z":"be91a2e4.eacc","name":"","links":["9327255d.b45df8"],"x":175,"y":500,"wires":[]},{"id":"3136d805.2b34d8","type":"link in","z":"be91a2e4.eacc","name":"Study Yeelight Switch Off","links":["1409fa23.77c346","f6e67908.88ba68","4256e4e.831931c"],"x":675,"y":520,"wires":[["75f9d6ce.449b08"]]},{"id":"23af6433.780bdc","type":"inject","z":"be91a2e4.eacc","name":"Blue","topic":"","payload":"0000FF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":670,"y":380,"wires":[["29f4c4c7.3a53cc"]]},{"id":"5c7beb14.1dab24","type":"tcp request","z":"be91a2e4.eacc","server":"192.168.1.116","port":"55443","out":"char","splitc":"\\n","name":"Call Study Yeelight","x":1130,"y":420,"wires":[["f61aaf5d.312eb"]]},{"id":"29f4c4c7.3a53cc","type":"function","z":"be91a2e4.eacc","name":"Yeelight Color/On Command","func":"\nvar brightness = 100;\nvar color = parseInt(msg.payload,16);\nif (isNaN(color)) {color=65535;}\n\nmsg.payload = \"{\\\"id\\\":0,\\\"method\\\":\\\"set_scene\\\", \\\"params\\\": [\\\"color\\\", \" + color + \", \" + brightness + \"]}\\r\\n\";\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":420,"wires":[["5c7beb14.1dab24"]]},{"id":"a8914bab.a604f8","type":"debug","z":"be91a2e4.eacc","name":"ZZZZ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1610,"y":420,"wires":[]},{"id":"f61aaf5d.312eb","type":"function","z":"be91a2e4.eacc","name":"Parse response buffer into string","func":"msg.payload = msg.payload.toString('utf8');\nreturn msg;","outputs":1,"noerr":0,"x":1390,"y":420,"wires":[["a8914bab.a604f8"]]},{"id":"42f583af.2dc67c","type":"link out","z":"be91a2e4.eacc","name":"","links":["9327255d.b45df8"],"x":535,"y":540,"wires":[]},{"id":"75f9d6ce.449b08","type":"function","z":"be91a2e4.eacc","name":"Yeelight Off Command","func":"msg.payload = \"{\\\"id\\\":1,\\\"method\\\":\\\"set_power\\\",\\\"params\\\":[\\\"off\\\", \\\"smooth\\\", 50]}\\r\\n\";\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":480,"wires":[["5c7beb14.1dab24"]]}]

@murraybrandon
Copy link

murraybrandon commented Mar 16, 2020

Sorry for the wrong code formatting - I tested that the above imports properly. In terms of node-red-contrib-yeelight-compat-hue, for some reason the globe would only accept commands sometimes, almost as if there were multiple threads trying to ping it with commands at the same time. I wrestled for half a day until I decided it was simpler to use a TCP/IP client. The above example has two entry points, one to flash once, another to flash twice. You could get a lot more elaborate with your commands by reading the Yeelight API spec. I liked the Yeelight 2 so much I bought another. If only it could be configured to not communicate over the cloud at all, and restrict to local network only ;)

@grumpazoid
Copy link

@murraybrandon Interesting you had some problems with sending commands. I did find a problem when using the node red dashboard to set values. The slider would send multiple messages in a short space of time and this caused it to stop responding for a short while. I solved this by just adding in a trigger node to limit the messages.
When it refused to respond via the dashboard I seem to remember that the Yeelight app still worked ok.

Thanks for the code - I have imported and will have a study.

@afrixx
Copy link

afrixx commented Apr 19, 2020

My Node-Red crashed also, because the Yeelights have been offline.
Here is my log:

Apr 19 20:10:23 ccu3-webui daemon.err node-red: Yeelight error { Error: read ECONNRESET
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
Apr 19 20:10:23 ccu3-webui daemon.err node-red: 19 Apr 20:10:23 - [red] Uncaught Exception:
Apr 19 20:10:23 ccu3-webui daemon.err node-red: 19 Apr 20:10:23 - TypeError: this.error is not a function
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at Yeelight.<anonymous> (/usr/local/addons/redmatic/var/node_modules/node-red-contrib-yeelight/yeelight/yeelight.js:36:22)
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at Yeelight.emit (events.js:198:13)
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at Yeelight.<anonymous> (/usr/local/addons/redmatic/var/node_modules/node-red-contrib-yeelight/node_modules/yeelight2/index.js:45:10)
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at Socket.emit (events.js:198:13)
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at emitErrorNT (internal/streams/destroy.js:91:8)
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
Apr 19 20:10:23 ccu3-webui daemon.err node-red:     at process._tickCallback (internal/process/next_tick.js:63:19)
Apr 19 20:10:23 ccu3-webui daemon.err node-red: Node-RED exited with non-zero exit status 1

Edit: I see, this bug has been already fixed.
@Gromina Could you release a new version including this fix?

Thanks a lot!

@murray
Copy link

murray commented Apr 19, 2020 via email

@michelefa1988
Copy link

Having the same issue, Node red completely crashes when a YEE light is offline. (nov 2020)

@afrixx
Copy link

afrixx commented Nov 21, 2020

I hope the recently released version 1.0.7 fixes this issue, I will try out later

@michelefa1988
Copy link

@afrixx , I installed the new version and it seems it does work. An exception is thrown but node red does not crash

@afrixx
Copy link

afrixx commented Nov 21, 2020

@afrixx , I installed the new version and it seems it does work. An exception is thrown but node red does not crash

Yes, I made the same observation.
There is still a warning:

Nov 21 15:30:47 ccu3-webui daemon.err node-red: (node:3408) UnhandledPromiseRejectionWarning: Error: Network timeout, Yeelight not response
Nov 21 15:30:47 ccu3-webui daemon.err node-red: at Timeout._onTimeout (/usr/local/addons/redmatic/var/node_modules/node-red-contrib-yeelight/node_modules/yeelight2/index.js:230:29)
Nov 21 15:30:47 ccu3-webui daemon.err node-red: at ontimeout (timers.js:436:11)
Nov 21 15:30:47 ccu3-webui daemon.err node-red: at tryOnTimeout (timers.js:300:5)
Nov 21 15:30:47 ccu3-webui daemon.err node-red: at listOnTimeout (timers.js:263:5)
Nov 21 15:30:47 ccu3-webui daemon.err node-red: at Timer.processTimers (timers.js:223:10)
Nov 21 15:30:47 ccu3-webui daemon.err node-red: (node:3408) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). (rejection id: 135)

@murray
Copy link

murray commented Nov 21, 2020 via email

@timonsku
Copy link
Collaborator

@murray you have subscribed yourself to this issue, the only way to not receive e-mails from it is to unsubscribe from it. No one has mentioned you directly.

@murray
Copy link

murray commented Nov 23, 2020

I was mentioned on Mar 15 by grumpazoid. But I will unsubscribe. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants