unltdnetworx / ioBroker.energymanager

ioBroker adapter for controlling kiwigrid powered devices
MIT License
10 stars 6 forks source link

crash directly after startup #31

Closed randomname32 closed 2 years ago

randomname32 commented 2 years ago

Hi, Since around 1 week ago my iobroker.energymanager (v1.3.3) crashes repeatedly. The logfile tells the following:

energymanager.0 2021-12-11 21:17:21.307 warn Terminated (UNCAUGHT_EXCEPTION): Without reason
energymanager.0 2021-12-11 21:17:21.303 info terminating
energymanager.0 2021-12-11 21:17:21.300 info cleaned everything up...
energymanager.0 2021-12-11 21:17:21.185 error Cannot read property 'replace' of null
energymanager.0 2021-12-11 21:17:21.183 error TypeError: Cannot read property 'replace' of null at Request._callback (/opt/iobroker/node_modules/iobroker.energymanager/main.js:218:42) at Request.self.callback (/opt/iobroker/node_modules/request/request.js:185:22) at Request.emit (events.js:314:20) at Request. (/opt/iobroker/node_modules/request/request.js:1154:10) at Request.emit (events.js:314:20) at IncomingMessage. (/opt/iobroker/node_modules/request/request.js:1076:12) at Object.onceWrapper (events.js:420:28) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1241:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)
energymanager.0 2021-12-11 21:17:21.177 error uncaught exception: Cannot read property 'replace' of null
energymanager.0 2021-12-11 21:17:20.526 info starting. Version 1.3.3 in /opt/iobroker/node_modules/iobroker.energymanager, node: v12.22.1, js-controller: 3.3.21

My SolarWatt EnergyManager runs the following Firmware: Version 7.32.1.0 Firmware 72101000

The SolarWatt EnergyManager seems to run fine, I can see the logged data on the solarwatt website alright.

It would be nice if this issue could be solved. If further information is needed I'm glad to help! Thank you

randomname32 commented 2 years ago

The json returned from the SolarManager indeed contained null at result.items[7].tagValues.IdName.value, which caused the crash of the iobroker adapter.

The problem seems to be that the SolarWatt EnergyManager automatically detects hardware it could control and returns that in the rest api. In my case it is a Keba Wallbox. I don't want to install/register the wallbox on my EnergyManager, because I want it to be controlled via iobroker.

When I install the Wallbox to the EnergyManager, the iobroker energymanager adapter does not crash anymore. When I uninstall the wallbox (and restart the EnergyManager), the iobroker adapter starts crashing again. So the crashing is reproducible.

Why didn't I notice this earlier? The EnergyManager only searches for devices in the network after a restart. I never restarted my EnergyManager, so until recently everything worked fine. But then I had a power outage which restarted it automatically. After that the errors happened.

Please add a null-check in line 216/217 of main.js. I think that this error might happen to others as well if they have a wallbox that is not installed in the EnergyManager.

unltdnetworx commented 2 years ago

Thanks for the reply. I try to implement this asap. Hope to get it fixed this week, as I'm short of time.

unltdnetworx commented 2 years ago

Okay, please try the version by installing it with github.

randomname32 commented 2 years ago

verified that it works. v1.3.3 crashed at startup, I installed v1.3.4 from github, no crash anymore, data is provided as expected. Thanks for the quick fix!