rlindner / node-red-contrib-sma-webconnect

Node-RED node to query the web interface of SMA inverters
MIT License
13 stars 9 forks source link

TypeError: Cannot read properties of undefined (reading 'name') #22

Closed botfixer closed 7 months ago

botfixer commented 2 years ago

I am using node-red on Windows.

When trying to use sma webconnect node an set it to SB Storage, everthing went fine.

After a view minutes this error occurs:

TypeError: Cannot read properties of undefined (reading 'name') at Request. (C:\Users\xxx.node-red\node_modules\node-red-contrib-sma-webconnect\sma-webconnect.js:181:42) at Request._callback (C:\Users\xxx.node-red\node_modules\lodash\lodash.js:10118:25) at Request.requestRetryReply [as reply] (C:\Users\xxx.node-red\node_modules\requestretry\index.js:115:19) at Request. (C:\Users\xxx.node-red\node_modules\requestretry\index.js:156:10) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5)

This is my flow. It just reads from Storage Boy every 20 seconds and give the payload to a debug node:

[ { "id": "0893e141ccde5782", "type": "tab", "label": "Test PV SB", "disabled": false, "info": "", "env": [] }, { "id": "2e82fb99f65e24de", "type": "debug", "z": "0893e141ccde5782", "name": "90", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "payload", "targetType": "msg", "statusVal": "payload", "statusType": "auto", "x": 670, "y": 200, "wires": [] }, { "id": "b1e69464c47ad1e4", "type": "interval", "z": "0893e141ccde5782", "name": "20s", "interval": "20", "onstart": true, "msg": "ping", "showstatus": false, "unit": "seconds", "statusformat": "YYYY-MM-D HH:mm:ss", "x": 230, "y": 240, "wires": [ [ "83729aa4341e3daf" ] ] }, { "id": "83729aa4341e3daf", "type": "sma-webconnect", "z": "0893e141ccde5782", "ip_address": "192.168.x.x", "right": "istl", "use_tls": true, "device_selection": "sb_storage", "x": 440, "y": 240, "wires": [ [ "2e82fb99f65e24de" ] ] } ]

HoLo85 commented 2 years ago

Sry for the late response. I currently can't test your flow, but it looks like the webconnect node is crashing during requesting the available sessions. Did you maybe restart the flow to often and did not close the sessions correct? This also can happen if you request data to fast from the SB storage unit.

botfixer commented 2 years ago

thank you for reply. It´s strange. I am using the nodes:

  1. Reading Tripower inverter
  2. Reading Sunny Boy inverter

When i use only one of them, it runs stable. When using both the same time, node-red crashes after a view seconds.

I then moved to Node-Red on Linux (Redmatic). Now everthing is ok, its actually running since a couple of weeks without issues.

Maybe something wrong when using Node-red on Windows.........

Nothing changed on the flow, it´s the same.

HoLo85 commented 2 years ago

Thank you for this information.

I'm using node-red with a Raspberry PI 3, I never tested it with Windows.

MakerMeik commented 2 years ago

For me, too, exactly this error message occurred again and again:

[error] TypeError: Cannot read properties of undefined (reading 'name') at Request. (/home/pi/.node-red/node_modules/node-red-contrib-sma-webconnect/sma-webconnect.js:181:42) at Request._callback (/home/pi/.node-red/node_modules/lodash/lodash.js:10118:25) ...

I have two SMA inverters here in the house, one for the PV system, one for the battery. So there are two sma-webconnect-nodes running in my Node-Red, which are set to different IPs. When they are triggered by a repeating inject-interval at the same time, the above error message occurs. I solved the problem for me by using the same 15-second-inject-node for both sma-webconnect-nodes, but for one I added a 7-s-delay in between.

Screenshot 2022-09-03 144233

faschmidt commented 1 year ago

Just for the record: I have the exakt same problem as the other contributors to this issue.

My Flow did the job for over a year continously on

Raspberry PI ZERO W Node-Red v2.X Node.js V14.x (i guess)

After the update to Node-Red V3.x and NodeJS V16.x the trouble began. I will try the workaround from MakerMeik ...

14 Mar 16:22:12 - [info] Flows sind gestartet 14 Mar 16:22:14 - [info] [sma-webconnect:7eaa0cc21224a301] session created: 192.168.178.34 : 5kFau1VH85HHM2Vf 14 Mar 16:22:14 - [info] [sma-webconnect:1eb31efdc7bbcf48] session created: 192.168.178.90 : 4wUfgxVWqBHWIz1c 14 Mar 16:22:14 - [red] Uncaught Exception: 14 Mar 16:22:14 - [error] TypeError: Cannot read properties of undefined (reading 'name') at Request. (/home/frank/.node-red/node_modules/node-red-contrib-sma-webcon nect/sma-webconnect.js:181:42) at Request._callback (/home/frank/.node-red/node_modules/lodash/lodash.js:10118:25) at Request.requestRetryReply [as reply] (/home/frank/.node-red/node_modules/requestret ry/index.js:115:19) at Request. (/home/frank/.node-red/node_modules/requestretry/index.js:156:1 0) at processTicksAndRejections (node:internal/process/task_queues:96:5) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'. nodered.service: Consumed 55.658s CPU time.

rlindner commented 1 year ago

Hello together, thanks to all of you for keeping on collecting your issues here. As you all seem to be using multiple instances of the node and the problem disappears after only using one or after using a delay to serialize the calls to the nodes, this raised a suspicion.

I've opened up a PR which might solve the issue. If anyone of you has JS knowledge, feel free to have a look and give feedback. :)