26 Oct 11:39:01 - [info] [zway-server:Zway-server] discoverDevices: Using cached devices
TypeError: Cannot read property 'title' of undefined
at /home/pi/.node-red/node_modules/node-red-contrib-zway/nodes/server.js:126:53
at ServerNode.discoverDevices (/home/pi/.node-red/node_modules/node-red-contrib-zway/nodes/server.js:92:17)
at ServerNode.getItemsList (/home/pi/.node-red/node_modules/node-red-contrib-zway/nodes/server.js:120:18)
at /home/pi/.node-red/node_modules/node-red-contrib-zway/zway.js:25:24
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:346:12)
I have checked the response from ZWay, and it contains a list of devices. They all have a metrics object including a title prop. I added some console.log statements, and it turns out that the for .. in construct seems to add an extra element, where the last element is a function! I also tried replacing with a plain for loop, and then that extra object is not included.
There are diffferent locations in server.js that iterates this way. Below is some code and corresponding log output from another part of the code. First, using the for .. in:
And then the plain old for loop:
I also tried a more modern .forEach approach, but then the server.js code seemed to not be executed at all.
Hardware / Software
- raspberry 4
version of zway firmware version: [v3.2.3]
zway UI version: [1.13.5]
node-red version: [v2.2.2]
- version of node-red-contrib-zway: [1.0.0]
- node version: [v14.20.0]
Describe issue crashes with "TypeError: Cannot read property 'title' of undefined" on last +1 element of list
Your flow here
Screens / Logs
I have checked the response from ZWay, and it contains a list of devices. They all have a
metrics
object including atitle
prop. I added some console.log statements, and it turns out that thefor .. in
construct seems to add an extra element, where the last element is a function! I also tried replacing with a plain for loop, and then that extra object is not included.There are diffferent locations in server.js that iterates this way. Below is some code and corresponding log output from another part of the code. First, using the
for .. in
:And then the plain old for loop:
I also tried a more modern
.forEach
approach, but then the server.js code seemed to not be executed at all.Hardware / Software
- raspberry 4