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

Connection failed to hue bridge / lamps #375

Open effen28 opened 2 years ago

effen28 commented 2 years ago

Hallo together,

since a few days ago (maybe since the update), I can not longer choose a lamp in the drop down. => it says, there went something wrong, try again

Unbenannt

also the Hue Bridge-Node says always connecting, but without success

image

Hope someone can support/help me

Thank you

andesse commented 2 years ago

This is a known behavior. Check all the recent bug reports.

andesse commented 2 years ago

Here my repository for https HUE API V2. It's just a flow with everything you need. https://github.com/andesse/node-red-hue-api.v2-flows

Travelbacon commented 2 years ago

@Foddy Can you take a look at this please? I have the exact same problems. Is there any help needed upgrading to the new API of Hue?

xyzo commented 2 years ago

@effen28 I do have the exact same issue and haven't found a solution so far. My Hue-Lights don't work anymore from their huemagic-nodes in Node Red :-(

andesse commented 2 years ago

@xyzo here. Very easy. You will be happy. https://github.com/andesse/hue-clip-api.node-red-flows

xyzo commented 2 years ago

@andesse I discovered that 30 mins ago. I already AM happy now :-D Thanks for your work!!

andesse commented 2 years ago

@xyzo cool, it won’t take long to set it up and you have zero issue for a long time, cause the api is brand new

xyzo commented 2 years ago

@andesse It works. Honestly I'd appreciate if there would be features like selecting rooms/lights/zones from within the nodes menus instead of copy and pasting UIDs everywhere.

To make sure: it works perfectly if you have digged yourself through everything what might be a bit difficult for people who are "only users". It's just a matter of being user friendly/intuitive...

xyzo commented 2 years ago

@andesse BTW: the comment node "lights - DOUBLE CLICK FOR INFO" is empty... no info on double-click :-)

andesse commented 2 years ago

@xyzo this is not a contrib. This is a flow that you change for your needs. I want that the users get contrib free and independent. So they have no struggle in the future when contribs don’t get updated.

Light Doubleclick. Can happen. I already have it in the readme at the end, that there could be mistakes. Lights are almost the same setup like rooms.

Follow my recommendation. Trigger scenes, not lights separate if possible. It’s important to read the full readme.

xyzo commented 2 years ago

@andesse I got you and I didn't want to upset you. Just saying that someone who doesn't have a clue about what is going on "inside" and just used huemagic before is now looking for something which works the same like huemagic. Some persons might be looking for similar solutions only.

You did great work with your tidy flow - really! It's just not a simple out-of-the-box-solution like before and still I see the advantages.

andesse commented 2 years ago

@andesse It works. Honestly I'd appreciate if there would be features like selecting rooms/lights/zones from within the nodes menus instead of copy and pasting UIDs everywhere.

To make sure: it works perfectly if you have digged yourself through everything what might be a bit difficult for people who are "only users". It's just a matter of being user friendly/intuitive...

I will never add this kind of features. These are parsed nodes again, that will not work some day if they are not maintained. If you want that, wait for HueMagic update.

xyzo commented 2 years ago

@andesse I won't wait :-) What I got now with your work is for MY needs perfect. More perfect then huemagic was before :-)

...I was just giving my thoughts and I didn't want to blame anyone instead of saying thank you.

andesse commented 2 years ago

Haha, yeah I got that. No worries. For me this solution has so many flows and examples now, that even only user people can do it when figured out. most work is Label link in nodes.

Thanks for your second comment. :) I am happy for everybody who can end struggling.

lukystreik commented 1 year ago

Initializing the bridge (192.168.1.122)… Connected to bridge Processing bridge resources… TypeError: Cannot read properties of undefined (reading 'owner')

Same here, since upgrading to the latest verion of nodered and huemagic, the connection to the brigde is broken. The Node status is "connecting". hue brigde Version 1.53.1953188020 nodejs 3.0.2 huemagic 4.2.2

Downgrade to 4.2.1 doesn´t fix the problem.

I have two bridges with the same current firmware. The first one works with no issues, the second have above problem

lukystreik commented 1 year ago

I´ve found the issue. If you add debug logs in the function this.fullResource in utils/api.js it is a lot easier to determine the problem! You should add something like that below on log stage debug:

//load the util function at the beginning of the api.js: const util = require('util');

... around line 185: // GET FULL/ROOT RESOURCE this.fullResource = function(resource, allResources = {}) { const scope = this; var fullResource = Object.assign({}, resource);

console.log("before Owner: " + util.inspect(resource,false, null, true /* enable colors */));

            if(resource["owner"])
            {

console.log("in Owner: " + util.inspect(resource["owner"],false, null, true /* enable colors */)); fullResource = scope.fullResource(allResources[fullResource["owner"]["rid"]], allResources); }

Bildschirmfoto 2022-10-16 um 13 50 06

Now we can see, witch is the case: Here in the group 6 a private group as owner is defined, witch can not processed by the huemagic api:

nodered-local-node-red-1 | vor Owner: { nodered-local-node-red-1 | id: 'beda2532-950b-4f9e-b8e1-653e1fcd5bbd', nodered-local-node-red-1 | id_v1: '/groups/6', nodered-local-node-red-1 | owner: { nodered-local-node-red-1 | rid: '867613e6-172e-4ae8-80e4-e8a8dc18cee1', nodered-local-node-red-1 | rtype: 'private_group' nodered-local-node-red-1 | }, nodered-local-node-red-1 | on: { on: false }, nodered-local-node-red-1 | alert: { action_values: [ 'breathe' ] }, nodered-local-node-red-1 | signaling: {}, nodered-local-node-red-1 | dynamics: {}, nodered-local-node-red-1 | type: 'grouped_light' nodered-local-node-red-1 | } nodered-local-node-red-1 | im Owner: { rid: '867613e6-172e-4ae8-80e4-e8a8dc18cee1', rtype: 'private_group' } nodered-local-node-red-1 | vor Owner: undefined nodered-local-node-red-1 | 16 Oct 13:46:03 - [info] [hue-bridge:vxhue2] TypeError: Cannot read properties of undefined (reading 'owner') nodered-local-node-red-1 | 16 Oct 13:46:03 - [red] Uncaught Exception: nodered-local-node-red-1 | 16 Oct 13:46:03 - [error] TypeError: Cannot read properties of undefined (reading 'owner') nodered-local-node-red-1 | at API.fullResource (/data/node_modules/node-red-contrib-huemagic/huemagic/utils/api.js:187:14) nodered-local-node-red-1 | at API.fullResource (/data/node_modules/node-red-contrib-huemagic/huemagic/utils/api.js:190:25) nodered-local-node-red-1 | at /data/node_modules/node-red-contrib-huemagic/huemagic/utils/api.js:247:30 nodered-local-node-red-1 | at Array.forEach () nodered-local-node-red-1 | at /data/node_modules/node-red-contrib-huemagic/huemagic/utils/api.js:244:14 nodered-local-node-red-1 | at new Promise () nodered-local-node-red-1 | at API.processResources (/data/node_modules/node-red-contrib-huemagic/huemagic/utils/api.js:224:10) nodered-local-node-red-1 | at /data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:92:47 nodered-local-node-red-1 | at processTicksAndRejections (node:internal/process/task_queues:96:5) nodered-local-node-red-1 exited with code 1

Therefore Object.assign() is the place, where the exception throwed

lukystreik commented 1 year ago

Quick fix: Ingore undefined objects like private_groups in api.js:

Bildschirmfoto 2022-10-16 um 16 40 51

line 176ff. in utils/api.js if (resource === undefined ) { console.log("huemagic: ignore undefined resources"); return allResources; }

zelloxy commented 1 year ago

I'd love for a fix for this, just begun setting up my flow and getting th "Connected to bridge" then the owner error.

andesse commented 1 year ago

@zelloxy

https://github.com/andesse/HUE-CLIP-API.Node-RED-Flows

Try this