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

Unplugging Hue Bridge Crashes Node-Red #237

Closed
andy99288 opened this issue May 29, 2021 · 5 comments
Closed

Unplugging Hue Bridge Crashes Node-Red #237

andy99288 opened this issue May 29, 2021 · 5 comments
Labels

Comments

@andy99288
Copy link

andy99288 commented May 29, 2021

Describe the bug
When I unplug the power or the ethernet to my hue bridge, shortly thereafter node-red crashes, restarts, crashes, repeat. I've searched the issues section here, but couldn't find anything I recognized as relevant.

Flow to Reproduce
I don't have any specific flows. As far as I know, my flows are great - things have been working really well. Recently I got the idea that I should place my 2 Hue Bridges on smart switches, in case I ever wanted to reboot them / cut their power I wouldn't have to pull out furniture. When playing with cutting their power, I noticed it completely took down node-red and put it in a restart loop until the hue bridge is available again. I've tried playing with the poll interval in the settings - placing it really high, but doesn't seem to make much of a difference. I have a lot of flows sending commands to the 2 hubs - they all seem to work well as long as the bridge is available.

Expected behavior
If I lose a hub, either by me unplugging it or it dying, or even a network failure, I'm hoping to keep it from taking down all of node-red.

Screenshots
None

Please complete the following information:

  • Node-RED version: 1.3.5
  • NodeJS version: 16.1.0
  • Device running Node-RED: Manjaro, inside VMWare on a windows machine

Additional context
I don't really need to cut power to the hue bridges - they are pretty stable. But I'm concerned now that if one of them dies or loses network it will break node-red.

@andy99288 andy99288 added the bug label May 29, 2021
@dionmes
Copy link

dionmes commented May 31, 2021

Same here, its not only unplugging. Its when in my case the raspberry loses the ethernet connection (due to restart of the router which I do on a nightly basis), HueJay creates a crash;
Error: Huejay: connect ENETUNREACH 192.168.1.55:80 - Local (0.0.0.0:0)

@patrickschaper
Copy link

Same here.
Looks like every time there is any connection error it crashes nodered.

Aug 19 14:12:07 main Node-RED[31330]: HuejayError: Huejay: read ECONNRESET
Aug 19 14:12:07 main Node-RED[31330]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Aug 19 14:12:07 main Node-RED[31330]:     at processTicksAndRejections (internal/process/task_queues.js:95:5) {
Aug 19 14:12:07 main Node-RED[31330]:   type: undefined
Aug 19 14:12:07 main Node-RED[31330]: }
Aug 19 14:12:07 main Node-RED[31330]: HuejayError: Huejay: read ECONNRESET
Aug 19 14:12:07 main Node-RED[31330]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Aug 19 14:12:07 main Node-RED[31330]:     at processTicksAndRejections (internal/process/task_queues.js:95:5) {
Aug 19 14:12:07 main Node-RED[31330]:   type: undefined
Aug 19 14:12:07 main Node-RED[31330]: }
Aug 19 14:12:07 main Node-RED[31330]: 19 Aug 14:12:07 - [red] Uncaught Exception:
Aug 19 14:12:07 main Node-RED[31330]: 19 Aug 14:12:07 - abort(Error: Huejay: read ECONNRESET). Build with -s ASSERTIONS=1 for more info.
Aug 19 14:12:07 main systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Aug 19 14:11:33 main Node-RED[31001]: HuejayError: Huejay: connect ECONNREFUSED 192.168.178.115:80
Aug 19 14:11:33 main Node-RED[31001]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Aug 19 14:11:33 main Node-RED[31001]:     at processTicksAndRejections (internal/process/task_queues.js:95:5) {
Aug 19 14:11:33 main Node-RED[31001]:   type: undefined
Aug 19 14:11:33 main Node-RED[31001]: }
Aug 19 14:11:33 main Node-RED[31001]: HuejayError: Huejay: connect ECONNREFUSED 192.168.178.115:80
Aug 19 14:11:33 main Node-RED[31001]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Aug 19 14:11:33 main Node-RED[31001]:     at processTicksAndRejections (internal/process/task_queues.js:95:5) {
Aug 19 14:11:33 main Node-RED[31001]:   type: undefined
Aug 19 14:11:33 main Node-RED[31001]: }
Aug 19 14:11:33 main Node-RED[31001]: 19 Aug 14:11:33 - [red] Uncaught Exception:
Aug 19 14:11:33 main Node-RED[31001]: 19 Aug 14:11:33 - abort(Error: Huejay: connect ECONNREFUSED 192.168.178.115:80). Build with -s ASSERTIONS=1 for more info.
Aug 19 14:11:33 main systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE

@dionmes
Copy link

dionmes commented Aug 21, 2021

So what I did as a hack to prevent this error is editing Transport.js in the Huejay module. Put a 'Return false;' at the latest catch to prevent the error being thrown. It works fine now. I might suggest a patch for Huemagic to have a try/catch in the Huejay call.

See hack in Transport.js below (I know its terrible).

return result;
      })
      .catch(error => {
	
	// Prevent network failures to throw errors
	return false;

        if (error instanceof HuejayError) {
          throw error;
        }

        throw new HuejayError({
          message: error.message
        });
	
      });
  }
}

module.exports = Transport;

Foddy added a commit that referenced this issue Jan 9, 2022
> **Attention!** HueMagic v4 + has been almost completely rewritten under the hood and requires at least the (square-shaped) Philips Hue Bridge firmware 1948086000+ from November 1st, 2021 ([Upgrade instructions](https://www.lighting.philips.com/content/B2C/en_US/microsites/meethue/marketing-catalog/huewireless_ca/support/security-advisory/general/where-and-how-can-i-update-my-hue-system-with-the-latest-software.html)) and Node-RED v1 + ([Upgrade instructions](https://nodered.org/docs/getting-started/local#upgrading-node-red)). If you are upgrading from a previous HueMagic version to the v4, you will have to reconfigure (not completely rebuild) all nodes by clicking them and selecting the appropriate device from the list. This also applies to nodes / functions that are operated in universal mode, as the numeric identifiers of the latest Philips Hue API version have been replaced in UUIDs. The nodes "Hue Switch", "Hue Button" & "Hue Tap" have been replaced in v4 by the universal and uniform node "Hue Buttons", which works with all button / switch devices that are connected to the Hue Bridge (please note here also the new API in the documentation). The request and return objects of the individual nodes are largely compatible with older HueMagic versions - with the exception of the nodes "Hue Bridge", "Hue Buttons", "Hue Scene" & "Hue Group". These need to be adjusted in the v4. Make sure that you meet the minimum technical requirements and have a quiet minute for the migration before upgrading to the v4.

* HueMagic speaks now directly with the bridge without any submodules *(huejay dependency removed)*
* Migrated to the newest CLIP/v2 API version from the Philips Hue bridge
* Nodes are now updated via push notifications (SSE) from the bridge instead of periodic polling
* Instant "current status" queries on each node with no loading time
* "Hue Buttons" node supports all new Philips Hue buttons/switches (e.g. Dimmer Switch v2, Hue Wall Switch…)
* All nodes provide additional property information in the output (check docs)
* New universal node "Hue Buttons" replaces the following nodes: "Hue Switch", "Hue Button", "Hue Tap"
* New "updated" object for all nodes, which only contains the properties that have been updated since the last state
* New configuration option to suppress first message after node initialization (for all nodes)
* New gradient color setting for compatible light sources (in "Hue Light node)
* New inject button for almost all nodes, which triggers the current status of a node
* New "universal mode" support for "Hue Rule" nodes
* New SVG-version of each node icon for higher quality rendering in the Node-RED UI
* New and full featured examples for each node right inside Node-RED
* New color mix feature in "Hue Light" nodes with the ability to mix the current light color with another
* New automatic brightness support based on the current time for "Hue Light" & "Hue Group" nodes
* New "Superhero", "Neon City" & "Christmas" (for next year, sorry) animations in "Hue Magic" node
* The custom alert effect on "Hue Light" & "Hue Group" nodes can now also be configured in brightness
* All nodes will now also forward the last command that has been applied ([#249](#249))
* "Hue Temperature" & "Hue Brightness" nodes can now also be activated & deactivated
* "Hue Light" & "Hue Group" nodes can now also receive XY color settings
* "Hue Light" & "Hue Group" can now also receive a named color temperature setting
* "Hue Light" & "Hue Group" nodes can now receive future brightness states in "turned off" mode ([#244](#244))
* Automatic light temperature setting outputs now values from 153 (coldest) to 500 (warmest)
* Automatic color correction based on the light´s capabilities for more accurate color settings
* Optimized node editor configuration UI to better match the current Node-RED´s UI
* The option for "automatic firmware updates" on the bridge moved to the bridge configuration node
* "Hue Group" node does no longer contain the "msg.info.model" & "msg.info.class" property
* Fixed timeout connection issues to the bridge
* Fixed an issue with non stopping custom animations ([#222](#222)), ([#224](#224)) & ([#226](#226)) (thx)
* Node-RED will no longer crash if there is no active connection to the bridge ([#237](#237))
* Fixed an issue that prevented the light / group from not reporting its own status when queried & node events were deactivated ([#248](#248))
* Fixed an issue with nodes in universal mode ([#245](#245))
* A possible attack target has been fixed ([#217](#217))
* Moved away from "moment.js" to "Day.js" for date/time formatting inside the nodes
* Updated README and help section on each node
* Updated dependencies to the latest version
@Foddy
Copy link
Owner

Foddy commented Jan 9, 2022

Fixed with v4

@Foddy Foddy closed this as completed Jan 9, 2022
@umiki7
Copy link

umiki7 commented Mar 4, 2022

For me the problem persists, on network loss, Node-red crashes, I have the following in the logs:
TypeError: Cannot read property 'length' of undefined at new HueBridgeMessage (/home/nodered/.node-red/node_modules/node-red-contrib-huemagic/huemagic/utils/messages.js:17:61) at HueBridge.get (/home/nodered/.node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:306:23) at /home/nodered/.node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge.js:84:30 at EventEmitter.<anonymous> (/home/nodered/.node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:556:7) at EventEmitter.emit (events.js:314:20) at HueBridge.pushUpdatedState (/home/nodered/.node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:275:16) at Timeout._onTimeout (/home/nodered/.node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:177:13) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)

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

No branches or pull requests

5 participants