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

Cannot read properties of undefined (reading 'getNodeLabelAttribute') #7

Open
macinspak opened this issue Jan 26, 2025 · 4 comments
Open

Comments

@macinspak
Copy link

macinspak commented Jan 26, 2025

Just capturing this for now. Haven’t had a chance to look at it.

I commissioned about 11 lights, then tried to copy/paste and existing command node. The copied node shows device and cluster empty (when before it was populated with the copied node values). Nodered then crashes with this in the logs.

Jan 26 21:49:34 homered Node-RED[19655]: #033[2m2025-01-26 21:49:34.781 FATAL  #033[0;1;90mLogger               #033[31mUnhandled error detected: #033[0;31mCannot read properties of undefined (reading 'getNodeLabelAttribute')
Jan 26 21:49:34 homered Node-RED[19655]:   #033[2;39mat #033[0m/home/pi/.node-red/dev/node-red-matter-controller/editor_apis.js#033[2m:58:30#033[0m
Jan 26 21:49:34 homered Node-RED[19655]: 26 Jan 21:49:34 - [red] Uncaught Exception:
Jan 26 21:49:34 homered Node-RED[19655]: 26 Jan 21:49:34 - [error] TypeError: Cannot read properties of undefined (reading 'getNodeLabelAttribute')
Jan 26 21:49:34 homered Node-RED[19655]:     at /home/pi/.node-red/dev/node-red-matter-controller/editor_apis.js:58:30
Jan 26 21:49:34 homered systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Jan 26 21:49:34 homered systemd[1]: nodered.service: Failed with result 'exit-code'.
@macinspak
Copy link
Author

macinspak commented Jan 26, 2025

Hmmm not sure what is going on here, I checked in the persist directory and the “nodes.commissionedNodes” file shows a couple of the lights added with the node labels I set, but most show as:
"nodeLabel":""
(Not sure if relevant).

The node-xxxxx.0.40.5 files all have the correct values for the nodeLabel.

The error seems to be in a part of the code that skips these:

…
if (endpoints.length == 1) {  //Simple Device OR Bridge
…

And instead goes here:

…
} else { //Composed Device
…

But not sure why as these are all nanoleaf downlights. And they all look the same in the config.
And they all worked while I had only added 10 devices. This only stopped working when I added the 11th one.

So either they are all a simple device and something else is causing it to go to the Composed Device code fragment, or they are all composed devices and something is wrong with the 11th one I added?

I am a bit blocked on this, are you able to maybe point me to a way I can debug what it’s failing on?

@sammachin
Copy link
Owner

If it’s a composed device you should get multiple devices in the device dropdown list with the name you allocated at commissioning followed by - [device type]
It’s possible the nanoleaf bulbs have a second device type on another endpoint for some proprietary clusters, in which case I’m not sure what you would see exactly.

I’m out at the moment but I’ll try with one of my nano leaf bulbs later

@macinspak
Copy link
Author

Thanks.

I tried this to get out of trouble:

                …
                } else { //Composed Device
                    info = conn.getRootClusterClient(BasicInformationCluster)
                        try {
                        info.getNodeLabelAttribute()
                        .then((nodeLabel) => {
                            endpoints.forEach((ep) => {
                                let name = ep.name.split('-')[1]
                                deviceList[`${nodeId}-${ep.number}`] = `${nodeLabel}-${name}`
                            })
                            listComplete = true
                        })
                        } catch (e) {
                                console.error(e);
                                endpoints.forEach((ep) => {
                                let name = ep.name.split('-')[1]
                                deviceList[`${nodeId}-${ep.number}`] = `XXXXXX-${name}`
                            })
                            listComplete = true
                        }
                }
                …

This got the interface not crashing. But it doesn’t really tell me anything.
I can see a blank name now in the list, how can I edit it or find out what it is?

@macinspak
Copy link
Author

OK, found it as the only unnamed one in nodes.commissionedNodes, I stopped node red and tried to set the name, but on restart the name gets erased in nodes.commissionedNodes. It must be coming from somewhere else and is writing it to that from the nodered process

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

2 participants