node-alarm-dot-com / homebridge-node-alarm-dot-com

Alarm.com plugin for Homebridge using Node.js
MIT License
58 stars 23 forks source link

Invalid account credentials crashes homebridge #116

Closed tbaur closed 1 week ago

tbaur commented 1 year ago

Describe the bug Alarm.com threw an error and the plugin crashed Homebridge entirely. Requires better error handling.

To Reproduce [9/18/2023, 9:18:48 AM] Error: GET https://www.alarm.com/web/api/identities failed: GET https://www.alarm.com/web/api/identities failed: [object Object] at /usr/local/lib/node_modules/homebridge-node-alarm-dot-com/node_modules/node-alarm-dot-com/dist/index.js:150:15 at processTicksAndRejections (node:internal/process/task_queues:95:5) at getIdentitiesState (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com/node_modules/node-alarm-dot-com/dist/index.js:134:12) at ADCPlatform.getAccountSettings (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com/src/index.ts:378:24) at ADCPlatform.refreshDevices (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com/src/index.ts:392:5) [9/18/2023, 9:18:48 AM] Got SIGTERM, shutting down Homebridge...

chase9 commented 1 year ago

Hi Tim,

Agreed, but what do you think the plugin should do when we encounter fatal errors? Do you think a red line warning in the log is enough?

Also, I'm guessing the error here is that login failed due to missing MFA but could you please confirm?

tbaur commented 1 year ago

Yeah. It could fail gracefully -- handle the error, report on it and not crash homebridge :) Then retry. Other plugins do this. It just needs better error handling here.

Looks like a server side error, not related to config. The API seems to fail sometimes, crash homebridge, then they recover and everything continues on.

tbaur commented 1 year ago

I'm not sure if this is applicable, something new the myQ plugin is doing to add even more failure handling...

[9/20/2023, 12:03:58 PM] [myQ] myQ API: Switched to myQ cloud region: west.

They have multiple API endpoints, east and west. The plugin sees a failure and switches the API endpoint used, continues on. In this case it has helped a lot, but it's also how myQ has built their infra. Bit of extra effort to keep the plugin rolling. Maybe alarm.com has different options.

chase9 commented 11 months ago

Just pushed up some code to the beta branch which will stop homebridge crashing the getAccountSettings() method fails.

tbaur commented 11 months ago

Cool, I’ve updated!

On Oct 19, 2023, at 4:43 PM, Chase Lau @.***> wrote:

Just pushed up some code to the beta branch which will stop homebridge crashing the getAccountSettings() method fails. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

chase9 commented 10 months ago

Fixed in b7736ea

chase9 commented 1 week ago

Resolved in stable v1.10.1