andesse / HUE-CLIP-API.Node-RED-Flows

Node-Red Flow to communicate with HUE CLIP API V2
The Unlicense
31 stars 4 forks source link

TypeError on Step 7 of the flow #27

Closed DaelDe closed 2 years ago

DaelDe commented 2 years ago

Describe the bug I did all steps of the install instructions. Then I added a single light id to one of the nodes in step 7 and deployed. When I now inject the timestamp to that node, the light properly changes but I get an error in the log: TypeError: Cannot read properties of undefined (reading 'name') . It originates from function node Light Name, ID, Abilities.

I did some further debugging. Input to the function node is (msg.payload):

{"data":[{"rid":"8be84fb5-cb86-4ae6-a057-9362bf9e2284","rtype":"light"}],"errors":[]}

According to Clip API v2 documentation, this is a valid response for PUT /resource/light/{id}.

The function node itself does expect a metadata property on the data objects. This property is not available. My Bridge is Up-To-Date. It seems your flow expects a different response. What could be wrong?

To Reproduce Steps to reproduce the behavior:

  1. Install the flow as described in the README of this repository
  2. Set Up a light in Step 7
  3. Trigger the light
  4. See error in debug window

Expected behavior No TypeError, instead info log that the light changed.

Desktop (please complete the following information):

andesse commented 2 years ago

Hi @DaelDe,

-please Check every Node again for typos.

Greetings Andreas

andesse commented 2 years ago

@DaelDe And the Flow does not need any response, you are talking directly with the Bridge. Please try to trigger a scene as well and have a look if you get any errors. scenes are the easiest.

DaelDe commented 2 years ago

Thanks for your reply.

I used the "light on / orange / 1s Transition" change node.

Everything with respect to the hue API is working correctly I think, the light is changing. However, the issue comes from the API response. The link in node "BRIDGE DATA RESPONSE IN" collects the result and sends it to change node Light Name, ID, Abilities. But this node expects a response from a "GET" call to the API. But controlling is done with "PUT" and therefore the response is different. In the screenshot you see the node and its input.

grafik

andesse commented 2 years ago

@DaelDe i think you mixed something up.

On the picture (red square) is the debug message from the https request node (yellowish) I can tell cause it shows the status code. 200 means everything fine.

The function node is only for the request of the IDs/Rids. They have a label in the flow that nothing need to be changed.

The error message itself comes out of the node that determines the data for the lights endpoint from the bridge. (I made a red arrow to the message)

IMG_3391

I can’t tell if you made some node connections that shouldn’t be there. The helper flow works on its own and completely fine when deploying the flow example.

Your upper arrow is pointing towards yadomi‘s hue-events-node when I see that right. this outputs the eventstream when the configuration is correct. I can’t see any payload coming from there on your screenshot.

You can disable the debug node from the light endpoint at the helper flow, and your error message will disappear.

Greetings Andreas

DaelDe commented 2 years ago

I did not change anything (just changed positions of nodes, wiring is untouched) on the flow but I understand it quite good so I can make my adaptions.

you said:

The function node is only for the request of the IDs/Rids. They have a label in the flow that nothing need to be changed.

However, it is directly wired to the API output, so it reacts on any API call and not only request of IDs/RIDs.

grafik

DaelDe commented 2 years ago

I will decouple ID/RID detection from other API calls and it should be fine. I just wonder why it does not happen on your side.

andesse commented 2 years ago

@DaelDe yes you are right with the output, I have just my phone on my hands and didn’t saw it correctly.

Yeah, you could do that, disable the link in node.

But I am still curious if you have a light setup with a special character in the name? When you requested all data in the ID helper flow, did all the arrays showed up and did you got all your data?

I can’t actually explain why this problem happens to you. You could try to import a copy of the whole flow and setup it another time.

But if your action api calls return a 200 everything is working as expected and you can ignore the message or decouple it.

DaelDe commented 2 years ago

Thank you for your support.

I will migrate my setup from huemagic to direct API calls. Maybe I can contribute something useful when I am finished let's see.

andesse commented 2 years ago

@DaelDe Thanks!