Foddy / node-red-contrib-huemagic

Philips Hue node to control bridges, lights, groups, motion sensors, temperature sensors and Lux sensors using Node-RED.
https://flows.nodered.org/node/node-red-contrib-huemagic
Apache License 2.0
201 stars 67 forks source link

Adding hue bridge does not work "503 bad gateway (nginx)" with nodered installed under Home Assistant (totally screwing the add on) #312

Open nibbsification opened 2 years ago

nibbsification commented 2 years ago

Describe the bug Prerequisits: I installed this package, as is want to use a friends of hue switch, which does not work out of the box with the Hue integration out of the box. At least I were not able to.

On the first try of adding the Hue bridge with the node "Hue Bridge" I was able to add my bridge, then it somehow did not work anymore (sorry, didnt log what exactly what went wrong) and now the add on does not work at all.

In the log of the HA add on, the following errors appear, when I try to start node red:

Welcome to Node-RED
===================
5 Feb 11:14:20 - [info] Node-RED version: v2.2.0
5 Feb 11:14:20 - [info] Node.js  version: v16.13.2
5 Feb 11:14:20 - [info] Linux 5.10.91 x64 LE
5 Feb 11:14:21 - [info] Loading palette nodes
5 Feb 11:14:22 - [info] Dashboard version 3.1.5 started at /endpoint/ui
Traceback (most recent call last):
  File "/opt/node_modules/node-red-node-pi-gpio/testgpio.py", line 3, in <module>
    import RPi.GPIO as GPIO
  File "/usr/lib/python3.9/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
5 Feb 11:14:23 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
5 Feb 11:14:23 - [info] Settings file  : /etc/node-red/config.js
5 Feb 11:14:23 - [info] Context store  : 'default' [module=memory]
5 Feb 11:14:23 - [info] User directory : /config/node-red/
5 Feb 11:14:23 - [warn] Projects disabled : editorTheme.projects.enabled=false
5 Feb 11:14:23 - [info] Flows file     : /config/node-red/flows.json
5 Feb 11:14:23 - [info] Server now running at http://127.0.0.1:46836/
5 Feb 11:14:23 - [info] Starting flows
5 Feb 11:14:23 - [info] [hue-bridge:Philips hue] Initializing the bridge (10.0.200.160)…
5 Feb 11:14:23 - [info] [hue-bridge:Philips hue] Connected to bridge
5 Feb 11:14:23 - [info] [hue-bridge:Philips hue] Processing bridge resources…
5 Feb 11:14:23 - [info] [hue-bridge:Philips hue] Initial emit of resource states…
5 Feb 11:14:24 - [info] [hue-bridge:Philips hue] Keeping nodes up-to-date…
5 Feb 11:14:24 - [info] [hue-bridge:Philips hue] Subscribing to bridge events…
5 Feb 11:14:24 - [red] Uncaught Exception:
5 Feb 11:14:24 - [error] TypeError: Cannot read properties of undefined (reading 'length')
    at new HueBridgeMessage (/config/node-red/node_modules/node-red-contrib-huemagic/huemagic/utils/messages.js:17:61)
    at HueBridge.get (/config/node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:306:23)
    at /config/node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge.js:84:30
    at EventEmitter.<anonymous> (/config/node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:556:7)
    at EventEmitter.emit (node:events:390:28)
    at HueBridge.pushUpdatedState (/config/node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:275:16)
    at Timeout._onTimeout (/config/node-red/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:177:13)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

Expected behavior At least, don't stop the instance from working completely. :)

Screenshots If applicable, add screenshots to help explain your problem.

Please complete the following information:

Additional context Add any other context about the problem here.

Any help i greatly appreciated.

Swiftnesses commented 2 years ago

+1 on this, killed my Home Assistant Node-RED instance :(

ptweety commented 2 years ago

This could be a duplicate of #302

nibbsification commented 2 years ago

Thanks for your reply. As of now, I won't try the workaround, that was mentioned in the linked thread, as I'm worried, that my flows will be lost (again) and were only recoverable by manually copy the code from /config/node-red/.flows.json.backup and I'm no sure, that will work every time. Looking forward to a stable pr/release, that will fix it.