lucacalcaterra / risco-mqtt-bridge

Risco Alarm panel to MQTT Server Bridge
MIT License
25 stars 9 forks source link

Giving error during polling #54

Open 03397 opened 1 year ago

03397 commented 1 year ago

The working instance that I have started throwing errors during polling. Any thoughts?

06-10-2023 21:42:26 debug: polling started... /app/app.js:91 this.lastEventString = (${todayNotErrEventsArray[0].YTimeToShow} ${todayNotErrEventsArray[0].EventName}).split(''').join(''); ^ TypeError: Cannot read properties of undefined (reading 'YTimeToShow') at RiscoPoller. (/app/app.js:91:62) at RiscoPoller.emit (node:events:513:28) at RiscoPoller.init (/app/panelPoller.js:35:10) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MqttClient. (/app/app.js:37:5) Node.js v18.12.1 06-10-2023 21:43:29 debug: Class Connection Constructor end 06-10-2023 21:43:29 info: Express server started... 06-10-2023 21:43:29 info: Connected to MQTT Server 06-10-2023 21:43:29 debug: Logged...Response code is 302: OK 06-10-2023 21:43:30 debug: ...site and Pin Code sent...Response code is 302: OK 06-10-2023 21:43:30 debug: ...Cameras taken...Response code is 200 and no data error: OK 06-10-2023 21:43:30 debug: ...Event History taken...Response code is 200 and no data error: OK 06-10-2023 21:43:31 debug: ...Detectors taken...Response code is 200 and no data error: OK 06-10-2023 21:43:31 debug: ...Overview taken...Response code is 200 and no data error: OK 06-10-2023 21:43:31 debug: return null, overview empty! 06-10-2023 21:43:31 debug: newarmstatus emitted 06-10-2023 21:43:31 info: Arming status: disarmed 06-10-2023 21:43:31 debug: Init function for getting data from Cloud completed: OK 06-10-2023 21:43:31 debug: polling started... /app/app.js:91 this.lastEventString = (${todayNotErrEventsArray[0].YTimeToShow} ${todayNotErrEventsArray[0].EventName}).split(''').join(''); ^ TypeError: Cannot read properties of undefined (reading 'YTimeToShow') at RiscoPoller. (/app/app.js:91:62) at RiscoPoller.emit (node:events:513:28) at RiscoPoller.init (/app/panelPoller.js:35:10) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MqttClient. (/app/app.js:37:5) Node.js v18.12.1 06-10-2023 21:44:36 debug: Class Connection Constructor end 06-10-2023 21:44:36 info: Express server started... 06-10-2023 21:44:36 info: Connected to MQTT Server 06-10-2023 21:44:37 debug: Logged...Response code is 302: OK 06-10-2023 21:44:37 debug: ...site and Pin Code sent...Response code is 302: OK 06-10-2023 21:44:37 debug: ...Cameras taken...Response code is 200 and no data error: OK 06-10-2023 21:44:37 debug: ...Event History taken...Response code is 200 and no data error: OK 06-10-2023 21:44:38 debug: ...Detectors taken...Response code is 200 and no data error: OK 06-10-2023 21:44:38 debug: ...Overview taken...Response code is 200 and no data error: OK 06-10-2023 21:44:38 debug: return null, overview empty! 06-10-2023 21:44:38 debug: newarmstatus emitted 06-10-2023 21:44:38 info: Arming status: disarmed 06-10-2023 21:44:38 debug: Init function for getting data from Cloud completed: OK 06-10-2023 21:44:38 debug: polling started... /app/app.js:91 this.lastEventString = (${todayNotErrEventsArray[0].YTimeToShow} ${todayNotErrEventsArray[0].EventName}).split(''').join(''); ^ TypeError: Cannot read properties of undefined (reading 'YTimeToShow') at RiscoPoller. (/app/app.js:91:62) at RiscoPoller.emit (node:events:513:28) at RiscoPoller.init (/app/panelPoller.js:35:10) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MqttClient. (/app/app.js:37:5) Node.js v18.12.1

03397 commented 9 months ago

This issue reappeared again. Can you please help?

03397 commented 9 months ago

Problem is solved. It seems that the problem appears when the electricity goes out and when it comes back the YTimeToShow for a reason that I cannot comprehend is not defined. If I arm/disarm the alarm manual then the apps starts behaving as it should be.

I guess that might want to add some checks to verify that todayNotErrEventsArray[0] is not undefined before attempting to access its properties.