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

Unhandeled error #86

Closed siglumous closed 2 years ago

siglumous commented 2 years ago

Describe the bug I get an "UNHANDLED ERROR" when trying to use the plugin. This occurs regardless of the plugin version. Currently I am running homebridge-node-alarm-dot-com v1.7.2-beta.10. 2FA is turned off.

To Reproduce Start Homebridge and receive the error message below.

Expected behavior I would expect the plugin to start up and work :)

Screenshots Here's the error message:

[8/9/2021, 18:52:46] [Security System] UNHANDLED ERROR: Error: GET https://www.alarm.com/web/api/devices/sensors?ids%5B%5D=100167024-95&ids%5B%5D=100167024-91&ids%5B%5D=100167024-81&ids%5B%5D=100167024-80&ids%5B%5D=100167024-79&ids%5B%5D=100167024-16&ids%5B%5D=100167024-17&ids%5B%5D=100167024-18&ids%5B%5D=100167024-19&ids%5B%5D=100167024-20&ids%5B%5D=100167024-21&ids%5B%5D=100167024-5&ids%5B%5D=100167024-77&ids%5B%5D=100167024-78&ids%5B%5D=100167024-96&ids%5B%5D=100167024-4&ids%5B%5D=100167024-73&ids%5B%5D=100167024-39&ids%5B%5D=100167024-40&ids%5B%5D=100167024-41&ids%5B%5D=100167024-42&ids%5B%5D=100167024-43&ids%5B%5D=100167024-44&ids%5B%5D=100167024-75&ids%5B%5D=100167024-84&ids%5B%5D=100167024-49&ids%5B%5D=100167024-1&ids%5B%5D=100167024-76&ids%5B%5D=100167024-8&ids%5B%5D=100167024-9&ids%5B%5D=100167024-10&ids%5B%5D=100167024-11&ids%5B%5D=100167024-12&ids%5B%5D=100167024-13&ids%5B%5D=100167024-14&ids%5B%5D=100167024-15&ids%5B%5D=100167024-3&ids%5B%5D=100167024-72&ids%5B%5D=100167024-87&ids%5B%5D=100167024-32&ids%5B%5D=100167024-33&ids%5B%5D=100167024-34&ids%5B%5D=100167024-35&ids%5B%5D=100167024-36&ids%5B%5D=100167024-37&ids%5B%5D=100167024-68&ids%5B%5D=100167024-7&ids%5B%5D=100167024-83&ids%5B%5D=100167024-65&ids%5B%5D=100167024-67&ids%5B%5D=100167024-58&ids%5B%5D=100167024-66&ids%5B%5D=100167024-55&ids%5B%5D=100167024-57&ids%5B%5D=100167024-2&ids%5B%5D=100167024-45&ids%5B%5D=100167024-70&ids%5B%5D=100167024-23&ids%5B%5D=100167024-24&ids%5B%5D=100167024-25&ids%5B%5D=100167024-26&ids%5B%5D=100167024-27&ids%5B%5D=100167024-28&ids%5B%5D=100167024-69&ids%5B%5D=100167024-85&ids%5B%5D=100167024-22&ids%5B%5D=100167024-90&ids%5B%5D=100167024-86&ids%5B%5D=100167024-71&ids%5B%5D=100167024-74&ids%5B%5D=100167024-29&ids%5B%5D=100167024-30&ids%5B%5D=100167024-31&ids%5B%5D=100167024-64&ids%5B%5D=100167024-54&ids%5B%5D=100167024-63&ids%5B%5D=100167024-89&ids%5B%5D=100167024-53&ids%5B%5D=100167024-93&ids%5B%5D=100167024-6&ids%5B%5D=100167024-82&ids%5B%5D=100167024-62&ids%5B%5D=100167024-92&ids%5B%5D=100167024-88&ids%5B%5D=100167024-51&ids%5B%5D=100167024-60&ids%5B%5D=100167024-56&ids%5B%5D=100167024-61&ids%5B%5D=100167024-50&ids%5B%5D=100167024-59&ids%5B%5D=100167024-52&ids%5B%5D=100167024-94&ids%5B%5D=100167024-46&ids%5B%5D=100167024-47&ids%5B%5D=100167024-48 failed: 404 at /usr/local/lib/node_modules/homebridge-node-alarm-dot-com/node_modules/node-alarm-dot-com/dist/index.js:464:15 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) at /usr/local/lib/node_modules/homebridge-node-alarm-dot-com/node_modules/node-alarm-dot-com/dist/index.js:147:39 at async Promise.all (index 0) at ADCPlatform.listDevices (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com/src/index.ts:299:26)

ADC-SystemStates.json

Homebridge System (please complete the following information):

Additional context Of note, I have 96 zones. Not sure if that is related to the issue. I've tried disabling zones such that only one is active, but get the same error message.

DMBlakeley commented 2 years ago

Believe that this is the same issue that was reported in issue #62.

I have submitted a PR for homebridge-node-alarm-dot-com-beta.11 as well as posted node-alarm-dot-com-beta.7 which I believe address this issue as well as #74 and #75. At this point @chase9 (the repository owner) has not responded to the PR.

anthonyb82 commented 2 years ago

Is there a way for me to load in beta 11 or do I need to wait for it to be pushed by the owner? I’ve been keeping my eye on the work down here by you for quite a few weeks now.

On Aug 9, 2021, at 6:32 PM, Doug B @.***> wrote:

 Believe that this is the same issue that was reported in issue #62.

I have submitted a PR for homebridge-node-alarm-dot-com-beta.11 as well as posted node-alarm-dot-com-beta.7 which I believe address this issue as well as #74 and #75. At this point @chase9 (the repository owner) has not responded to the PR.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

DMBlakeley commented 2 years ago

Ideally the owner should agree to the PR and post. I will see if I can publish in my account and not conflict with the original version.

siglumous commented 2 years ago

Thanks @DMBlakeley. I installed the plugin from your fork and get the following error upon startup:

[8/11/2021, 10:21:46] ==================== [8/11/2021, 10:21:46] ERROR LOADING PLUGIN homebridge-node-alarm-dot-com-2: [8/11/2021, 10:21:46] /usr/local/lib/node_modules/homebridge-node-alarm-dot-com-2/node_modules/node-fetch/src/index.js:9 import http from 'http'; ^^^^^^

SyntaxError: Cannot use import statement outside a module at Module._compile (internal/modules/cjs/loader.js:892:18) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Module.require (internal/modules/cjs/loader.js:849:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com-2/node_modules/node-alarm-dot-com-2/dist/index.js:22:38) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) [8/11/2021, 10:21:46] ====================

Hoping this is something simple I'm missing?

DMBlakeley commented 2 years ago

I am trying to understand the cause for this error. Your error is a bit different than what I am seeing but still pointing to node-fetch as the problem area. What is your configuration?

siglumous commented 2 years ago

By configuration are you asking for environment/OS? Here's what I'm running currently:

Raspberry Pi Node.js Version: v12.13.0 NPM Version: v6.12.1 Homebridge Version: v1.3.4 Operating System: Raspbian GNU/Linux Stretch (9) Process Supervisor: Systemd

And thanks again--appreciate the assist.

DMBlakeley commented 2 years ago

@siglumous , appreciate if you would try updating the homebridge-node-alarm-dot-com-2 plugin to the latest version and see if it addresses your issue.

I have it running on a RPi with the following configuration:

Node.js Version: v14.17.4 NPM Version: v7.20.3 Homebridge Version: v1.3.4 Operating System: Raspbian GNU/Linux Buster (10)

DMBlakeley commented 2 years ago

homebridge-node-alarm-dot-com@beta.11 has now been posted. You may want to give this a try.

anthonyb82 commented 2 years ago

Thanks for the heads up. Deleted plugin and started fresh on beta 11. Installed and running with no issues. Will update in a couple of days. Thanks for your work on this.

Anthony

On Aug 11, 2021, at 5:51 PM, Doug B @.***> wrote:

 @.*** has now been posted. You may want to give this a try.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

siglumous commented 2 years ago

So, updated everything (new Homebridge RaspberryPi image) and set up the homebridge-node-alarm-dot-com-2 plugin but still get the same error. It's an unhandled error for a 404 response. Could it be due to the large number of zones I have (96)? It seems to query the alarm panel and gets back the very long URL that lists all the zones...but then craps out after the 48th zone...at least in the error string.

Here it is again:

[12/08/2021, 15:01:26] [Security System2] Logged into Alarm.com as xxxxx@gmail.com [12/08/2021, 15:01:40] [Security System2] UNHANDLED ERROR: Error: GET https://www.alarm.com/web/api/devices/sensors?ids%5B%5D=100167024-95&ids%5B%5D=100167024-91&ids%5B%5D=100167024-81&ids%5B%5D=100167024-80&ids%5B%5D=100167024-79&ids%5B%5D=100167024-16&ids%5B%5D=100167024-17&ids%5B%5D=100167024-18&ids%5B%5D=100167024-19&ids%5B%5D=100167024-20&ids%5B%5D=100167024-21&ids%5B%5D=100167024-5&ids%5B%5D=100167024-77&ids%5B%5D=100167024-78&ids%5B%5D=100167024-96&ids%5B%5D=100167024-4&ids%5B%5D=100167024-73&ids%5B%5D=100167024-39&ids%5B%5D=100167024-40&ids%5B%5D=100167024-41&ids%5B%5D=100167024-42&ids%5B%5D=100167024-43&ids%5B%5D=100167024-44&ids%5B%5D=100167024-75&ids%5B%5D=100167024-84&ids%5B%5D=100167024-49&ids%5B%5D=100167024-1&ids%5B%5D=100167024-76&ids%5B%5D=100167024-8&ids%5B%5D=100167024-9&ids%5B%5D=100167024-10&ids%5B%5D=100167024-11&ids%5B%5D=100167024-12&ids%5B%5D=100167024-13&ids%5B%5D=100167024-14&ids%5B%5D=100167024-15&ids%5B%5D=100167024-3&ids%5B%5D=100167024-72&ids%5B%5D=100167024-87&ids%5B%5D=100167024-32&ids%5B%5D=100167024-33&ids%5B%5D=100167024-34&ids%5B%5D=100167024-35&ids%5B%5D=100167024-36&ids%5B%5D=100167024-37&ids%5B%5D=100167024-68&ids%5B%5D=100167024-7&ids%5B%5D=100167024-83&ids%5B%5D=100167024-65&ids%5B%5D=100167024-67&ids%5B%5D=100167024-58&ids%5B%5D=100167024-66&ids%5B%5D=100167024-55&ids%5B%5D=100167024-57&ids%5B%5D=100167024-2&ids%5B%5D=100167024-45&ids%5B%5D=100167024-70&ids%5B%5D=100167024-23&ids%5B%5D=100167024-24&ids%5B%5D=100167024-25&ids%5B%5D=100167024-26&ids%5B%5D=100167024-27&ids%5B%5D=100167024-28&ids%5B%5D=100167024-69&ids%5B%5D=100167024-85&ids%5B%5D=100167024-22&ids%5B%5D=100167024-90&ids%5B%5D=100167024-86&ids%5B%5D=100167024-71&ids%5B%5D=100167024-74&ids%5B%5D=100167024-29&ids%5B%5D=100167024-30&ids%5B%5D=100167024-31&ids%5B%5D=100167024-64&ids%5B%5D=100167024-54&ids%5B%5D=100167024-63&ids%5B%5D=100167024-89&ids%5B%5D=100167024-53&ids%5B%5D=100167024-93&ids%5B%5D=100167024-6&ids%5B%5D=100167024-82&ids%5B%5D=100167024-62&ids%5B%5D=100167024-92&ids%5B%5D=100167024-88&ids%5B%5D=100167024-51&ids%5B%5D=100167024-60&ids%5B%5D=100167024-56&ids%5B%5D=100167024-61&ids%5B%5D=100167024-50&ids%5B%5D=100167024-59&ids%5B%5D=100167024-52&ids%5B%5D=100167024-94&ids%5B%5D=100167024-46&ids%5B%5D=100167024-47&ids%5B%5D=100167024-48 failed: 404 at get (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com-2/node_modules/node-alarm-dot-com-2/dist/index.js:465:15) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5) at authenticatedGet (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com-2/node_modules/node-alarm-dot-com-2/dist/index.js:423:17) at Object.getCurrentState (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com-2/node_modules/node-alarm-dot-com-2/dist/index.js:146:35) at async Promise.all (index 0) at ADCPlatform.listDevices (/usr/local/lib/node_modules/homebridge-node-alarm-dot-com-2/src/index.ts:309:26)

DMBlakeley commented 2 years ago

First, want to let you know that homebridge-node-alarm-dot-com@beta.11 has been updated to merge the com-2 improvments. You should switch to this plug-in going forward but will not produce a different result.

I will look into your issue. Could you let me know which RaspPi you are using and the RAM size.

siglumous commented 2 years ago

Thanks again.

Raspberry Pi 2 Model B Rev 1.1

Hardware : BCM2835 Revision : a21041 Serial : 000000008c113d61 Model : Raspberry Pi 2 Model B Rev 1.1 a21041 | Q1 2015 | 2 Model B | 1.1 | 1 GB | (Mfg by Embest)

DMBlakeley commented 2 years ago

I've done a bit of digging ...

First, wanted to check that problem was not a RAM issue on your RPi. I have a Pi4 with 2GB running with the plugin as well as config-ui-x. Says that there is 1.83 GB Total, 1.59 G Available. With your 1GB Pi you should not have an issue with 0.6GB available. This is why I asked.

Second, wondered if there was a buffer size issue with node-fetch. Default is 16k bytes, again not an issue.

Looking more closely at the error I find that the status of all 96 devices are being requested at once. They are not listed in numerical order and why it appears that only 48 are being requested but if you dissect you see that all are being requested.

It appears to me that there is a limit to the number of devices that can be requested in a single request to the Alarm.com servers. The I only have 6 devices and is clearly not an issue. Not sure what the limit is. You might be able to find out by adding devices to the ignored device list until the error goes away. The code would then need to be updated to fetch the status in batches of n devices.

@chase9, can you add any insight on maximum number of devices can be requested?

siglumous commented 2 years ago

Thanks @DMBlakeley. I have added all but one device to the ignored list and get the same error. So, I think the code must first poll the system to get the full list, then filter out?

This is a new-ish house to us and we inherited the alarm system. 96 devices is certainly overkill, but given they are all installed/connected/operational at the panel and with alarm.com, I'd like to leverage them if possible. Thanks again.

DMBlakeley commented 2 years ago

Interesting. I am hoping that @chase9 can add some insight as he has the most experience with the Alarm.com API. Also wonder if others with 10's of devices could help in understanding the batch size that would work. Worry would be that too small a batch size and associated polling would trigger blocking on the Alarm.com side.

chase9 commented 2 years ago

It's hard to say without any actual documentation from alarm.com, but i can confirm there appears to be an upper limit on how many devices can be included in a call at a time. I believe this is just because the url called is some 2,000 chars long. I would be interested to see how the alarm.com web client checks on these devices on your account.

I would bet we can work around this by batching these checks into groups of no longer than 10 devices in order to keep the calls reasonable.

siglumous commented 2 years ago

What can I do to show you how the web client checks the devices on alarm.com? Thanks.

chase9 commented 2 years ago

Hi @siglumous. This process will very likely include sensitive information, so make sure you trust me before submitting anything :)

The easiest way I can think of is to do this:

  1. Open Chrome
  2. Go to alarm.com. Login if needed. End up on the home page.
  3. Right click the webpage and select "Inspect". Navigate to the "Network" tab to begin logging your traffic
  4. Refresh the page
  5. Click on the "sensors" tab to make sure all of them are loaded.
  6. Click the red stop button in the upper left of the networking pane/window to stop recording.
  7. Right click the list of network requests and select "Save all as HAR with Content"
  8. Save that file and email it to git AT chaselau DOT me

Please remember to only start recording after you've logged in so you don't send me your login credentials!

siglumous commented 2 years ago

Sent. Thanks.

chase9 commented 2 years ago

Received.

I can see that your web portal does split he sensors call into two different calls. The first one has 95 devices and the second one has the rest (7 devices). I think the path forward should be to batch calls by 90 devices which should keep us under any char or device limit.

For now, you should be able to alleviate your problem by ignoring ~7 devices. Could you tell me if that works?

siglumous commented 2 years ago

Thanks. I'll need to actually disable the sensors at the panel since ignoring within alarm-dot-com plugin doesn't work. This will take a few days since I need to wait until everyone is out of the house--the beeping and reset results in lots of unhappy family members including the dogs :). Should be able to get to it soon though. Actually, I may be able to disable in the Alarm.com console--perhaps that's what you're suggesting. I'll try that now...

chase9 commented 2 years ago

Actually, the beta version of the plug-in fixed ignoring devices. You may want to try that :)

Chase

Please excuse any grammatical errors as this was sent from my iPhone.

On Aug 19, 2021, at 7:41 AM, siglumous @.***> wrote:

 Thanks. I'll need to actually disable the sensors at the panel since ignoring within alarm-dot-com plugin doesn't work. This will take a few days since I need to wait until everyone is out of the house--the beeping and reset results in lots of unhappy family members including the dogs :). Should be able to get to it soon though. Actually, I may be able to disable in the Alarm.com console--perhaps that's what you're suggesting. I'll try that now...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

siglumous commented 2 years ago

Just added 11 devices to the ignored list but got the exact same error message. The devices I added to the ignored list are the last 11 that show up on the earlier (and current) error message. It does seem that the plugin initially queries the system to get the full list...and that's when it craps out. I'll try disabling in the system itself but it will likely have to be this weekend.

chase9 commented 2 years ago

Would you mind submitting an issue for this not being ignored? I'd like to track it.

chase9 commented 2 years ago

Closing this to track in #62

DMBlakeley commented 2 years ago

You may want to check if the 11 devices that you added to the ignore list have been removed from the Homebridge cache also. This can be done by going to the Homebridge settings and then "Remove Single Cached Accessories".