hjdhjd / homebridge-myq

:car: myQ Liftmaster and Chamberlain Plugin for Homebridge https://github.com/nfarina/homebridge
Other
569 stars 44 forks source link

Error when running homebridge - UnhandledPromiseRejectionWarning: TypeError #71

Closed LampeMW closed 4 years ago

LampeMW commented 4 years ago

I recently updated to the newest version of homebridge as well as the newest version of homebridge-myq2, and am now getting this error when running homebridge. I'm not quite sure how to debug this and wanted to see if you could help figure it out.

(node:104498) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getCharacteristic' of undefined
    at /usr/lib/node_modules/homebridge-myq2/dist/index.js:238:21
    at Array.forEach (<anonymous>)
    at myQPlatform.myQUpdateDeviceList (/usr/lib/node_modules/homebridge-myq2/src/index.ts:264:22)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at myQPlatform.updateAccessories (/usr/lib/node_modules/homebridge-myq2/src/index.ts:423:5)
(node:104498) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Here's a sample of my config json:

{
        "bridge": {
                "name": "Homebridge",
                "username": "redacted",
                "port": 51826,
                "pin": "123-45-678"
        },
        "platforms": [
                {
                        "platform": "myQ",
                        "email": "redacted",
                        "password": "redacted"
                }
        ]
}

Thanks!

hjdhjd commented 4 years ago

@LampeMW and others...can you verify? I’m suspicious of the above...but give it a whirl.

BindersFullOfWomen commented 4 years ago

Can’t test tonight but I will check tomorrow to see if rolling back and then re-updating resolves the issue.

markcsegal commented 4 years ago

So to verify you want me to downgrade validate they work and re upgrade? Do you want any logging?

heccoder commented 4 years ago

@hjdhjd I downgraded from 2.1.0 to 2.0.13 per your post and it worked, no more errors, then decided to upgrade again to 2.1.0 and so far no issues.

hjdhjd commented 4 years ago

Thanks for the report @sonoseco . These types of bugs and bug reports are the stuff nightmares are made of.

Mysteriously come and go. Some weird magic incantation seems to fix it. But nobody exactly knows why.

Ugh. Would be good to see if others solve this in the same way...

Thanks all.

maelstromchanneled commented 4 years ago

I suggest that there might be some setting either on the HomeBridge side or even on the HomeKit side that, once set in 2.0.13, persisted to 2.1.0.

If you can get ahold of of few folks who haven’t yet migrated, you might try having half of them go to 2.0.13 first, and the other half 2.1.0 first, and collect as much debug data as possible to isolate the setting.

Also, I wonder if someone starting fresh in HomeBridge could go straight to 2.1.0? Unfortunately, I think that hard resetting HomeBridge causes HomeKit automations to get munged, so it might be hard to get a volunteer for that I guess.

dakotahp commented 4 years ago

I’m one of those on the current version that doesn’t work and am too lazy to downgrade because I run homebridge in a docker container which makes it more complicated. I’d be fine adding more explicit debugging output in a new release. It’s a bit drastic but there have been many releases in the last week so who cares. I would hope that the error ‘TypeError: Cannot read property 'getCharacteristic' of undefined
at /usr/local/lib/node_modules/homebridge-myq2/dist/index.js:242:21’ would make more sense with a lot of debugging output that shows API responses, if not already logged in steps above.

hjdhjd commented 4 years ago

@dakotahp I know what the error is, and it’s not an API error. I’m not ready to point fingers to anything other than my own code quite yet, but it sure feels like a bug in TS or homebridge we’re inadvertently running into.

If you want to give it a shot on a clean setup, go for it...you can always just launch a new docker container with a clean homebridge install and add this plugin to it. There’s nothing that says you can’t have more than one homebridge instance running on your network (just make sure the ports aren’t the same if on the same machine/VM). That should make it pretty trivial for most to test without forcing people to nuke their environments for the sake of testing theories and chasing bugs down. :smile:

BindersFullOfWomen commented 4 years ago

@maelstromchanneled Can confirm that between 2.0.13 and 2.1.0 something broke?

If so...that’s super helpful. If you wouldn’t mind testing for posterity...

I can confirm. After rolling back to 2.0.13 the garage door showed back up and the errors stopped showing up in the logs.

markcsegal commented 4 years ago

@hjdhjd I haven't done anything. Let me know if you need some debug logs. I can also setup a VM if needed and do a clean install.

hjdhjd commented 4 years ago

@maelstromchanneled Can confirm that between 2.0.13 and 2.1.0 something broke? If so...that’s super helpful. If you wouldn’t mind testing for posterity...

I can confirm. After rolling back to 2.0.13 the garage door showed back up and the errors stopped showing up in the logs.

@BindersFullOfWomen Can you re-upgrade to 2.1.0 and see if that works?

justinrhodes commented 4 years ago

I just removed 2.1.0, reinstalled 2.0.13 (left the setup untouched), updated to 2.1.0 and I'm still seeing this.

hjdhjd commented 4 years ago

@justinrhodes Out of curiosity, did you follow all the instructions from here or just a straight uninstall old version / install new version?

justinrhodes commented 4 years ago

@justinrhodes Out of curiosity, did you follow all the instructions from here or just a straight uninstall old version / install new version?

Just straight uninstall / install

hjdhjd commented 4 years ago

@justinrhodes Would you mind trying the above method and seeing if that works?

justinrhodes commented 4 years ago

@justinrhodes Would you mind trying the above method and seeing if that works?

Just walked through those steps and I am now able to see everything working properly with the garage door recognized and no errors in the log.

hjdhjd commented 4 years ago

@justinrhodes Well, on the plus side, we know how to solve the issue. On the minus side, still sorting out why the errors happen to begin with. It’s quite odd.

If you’re down for it...I’d be curious to know if there are issues installing this on a virgin homebridge install. I’ve been unable to recreate the issue on my end.

justinrhodes commented 4 years ago

@justinrhodes Well, on the plus side, we know how to solve the issue. On the minus side, still sorting out why the errors happen to begin with. It’s quite odd.

If you’re down for it...I’d be curious to know if there are issues installing this on a virgin homebridge install. I’ve been unable to recreate the issue on my end.

Sure. I'm running in a Docker. I can just spin up a new instance...standby

justinrhodes commented 4 years ago

New instance of HB + 2.1.0 plugin resulted in hitting this issue.

hjdhjd commented 4 years ago

@justinrhodes Thanks Justin. What version of HB is it? Were there any other plugins live, or just homebridge-myq2?

Now I’ve got something to work with to track this down. :)

BindersFullOfWomen commented 4 years ago

following the uninstall reinstall work flow posted above didn't resolve the issue for me.

Disregard. Uninstalling 2.0.13 and then installing 2.1.0 through Homebridge UI X resolved the problem. Garage is showing up in Home and no error messages.

markcsegal commented 4 years ago

I uninstalled, left the config. Forced and install of 2.0.13, restarted, no devices.. then upgraded 2.1.0, still no devices.

justinrhodes commented 4 years ago

@justinrhodes Thanks Justin. What version of HB is it? Were there any other plugins live, or just homebridge-myq2?

Now I’ve got something to work with to track this down. :)

homebridge -V
1.1.1

This is running through the oznu/homebridge Docker container which always includes these plugins by default:

homebridge-config-ui-x homebridge-dummy

maelstromchanneled commented 4 years ago

I uninstalled, left the config. Forced and install of 2.0.13, restarted, no devices.. then upgraded 2.1.0, still no devices.

@markcsegal, when you were in 2.0.13, did you check the HomeBridge log for myQ errors, and then try to connect HomeKit to verify devices? If you aren't seeing devices in HomeKit with 2.0.13, would be good to get your HomeBridge error logs.

markcsegal commented 4 years ago

@maelstromchanneled Same notice in the log.

[7/8/2020, 16:00:43] [myQ] Successfully connected to the myQ API.

I don't have debug turned on, but can if it will help.

maelstromchanneled commented 4 years ago

Wait, is that the last message you get in the logs with 2.0.13, but you still aren't seeing any devices in HomeKit?

markcsegal commented 4 years ago

Yes. just like on 2.1.0

On Wed, Jul 8, 2020 at 1:09 PM maelstromchanneled notifications@github.com wrote:

Wait, is that the last message you get in the logs with 2.0.13, but you still aren't seeing any devices in HomeKit?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hjdhjd/homebridge-myq2/issues/71#issuecomment-655644809, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4EC2H5MCDM3TMU4I2MLHTR2SR5LANCNFSM4ORVPJJQ .

maelstromchanneled commented 4 years ago

@markcsegal ... that might be a different issue. Even with debug=false, you should be seeing these kinds of log entries all together:

[7/6/2020, 12:46:43 PM] [myQ] Successfully connected to the myQ API.
[7/6/2020, 12:46:43 PM] [myQ] myQ gateway device discovered: Garage Door Hub (serial number: REDACTED).
[7/6/2020, 12:46:43 PM] [myQ] myQ garagedoor device discovered: Main Garage Door (serial number: REDACTED, gateway: REDACTED).

and then, if you are having the issue, you should see this entry:

(node:50) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getCharacteristic' of undefined
    at /usr/local/lib/node_modules/homebridge-myq2/dist/index.js:238:21
    at Array.forEach (<anonymous>)
    at myQPlatform.myQUpdateDeviceList (/usr/local/lib/node_modules/homebridge-myq2/src/index.ts:264:22)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) 
    at myQPlatform.updateAccessories (/usr/local/lib/node_modules/homebridge-myq2/src/index.ts:423:5)
(node:50) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside
of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the
node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict`
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:50) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections
that are not handled will terminate the Node.js process with a non-zero exit code.
markcsegal commented 4 years ago

that was what I opened as issue 72 :), but it was merged.

maelstromchanneled commented 4 years ago

that was what I opened as issue 72 :), but it was merged.

Ok, I don't know if it will help @hjdhjd, but I'd recommend forcing the install to 2.0.13 and changing to "debug"=true in your config.json. Post all the myQ log output lines -- it is weird that it is saying that the myQ API is connecting but then nothing more happens.

markcsegal commented 4 years ago

Here it is on 2.1.0:

[7/8/2020, 21:42:11] [myQ] { SecurityToken: 'reacted' } [7/8/2020, 21:42:11] [myQ] Successfully connected to the myQ API. [7/8/2020, 21:42:11] [myQ] Token: reacted [7/8/2020, 21:42:12] [myQ] { Account: { AccessGroups: { href: 'http://api.myqdevice.com/api/v5/Accounts/redacted/AccessGroups' }, AccessSchedules: { href: 'http://api.myqdevice.com/api/v5/Accounts/redacted/AccessSchedules' }, Address: { AddressLine1: 'redacted', AddressLine2: 'Toronto', City: 'Toronto', Country: { Code: 'CAN', IsEEACountry: false, href: 'http://api.myqdevice.com/api/v5/Countries/CAN' }, PostalCode: 'redact', State: 'Ontario' }, ContactName: 'redact', Devices: { href: 'http://api.myqdevice.com/api/v5/Accounts/redacted/Devices' }, DirectoryCodeLength: 0, Email: 'redacted', Id: 'redacted', Name: "Mark's Home", Phone: 'redacted', Roles: { href: 'http://api.myqdevice.com/api/v5/Accounts/redacted/Roles' }, TimeZone: 'America/New_York', UserAllowance: 4, Users: { href: 'http://api.myqdevice.com/api/v5/Accounts/redacted/Users' }, Zones: { href: 'http://api.myqdevice.com/api/v5/Accounts/redacted/Zones' }, href: 'http://api.myqdevice.com/api/v5/Accounts/redacted' }, Address: { AddressLine1: 'redacted', AddressLine2: 'Toronto', City: 'Toronto', Country: { Code: 'CAN', IsEEACountry: false, href: 'http://api.myqdevice.com/api/v5/Countries/CAN' }, PostalCode: 'redacted' }, Admin: false, AnalyticsId: 'redacted', CultureCode: 'en', DiagnosticDataOptIn: true, Email: 'redacted', FirstName: 'Mark', LastName: 'Segal', MailingListOptIn: false, Phone: 'redacted', RequestAccountLinkInfo: false, TimeZone: { Id: 'America/New_York', Name: 'America/New_York' }, UserId: 'redacted', UserName: 'redacted', Users: { href: 'http://api.myqdevice.com/api/v5/My/Users' } } [7/8/2020, 21:42:12] [myQ] myQ accountID: redacted [7/8/2020, 21:42:12] [myQ] { count: 0, href: 'http://api.myqdevice.com/api/v5/accounts/redacted/devices', items: [] } [7/8/2020, 21:42:12] [myQ] Throttling myQ API call. Using cached data from the past five seconds. [7/8/2020, 21:42:26] [myQ] { count: 0, href: 'http://api.myqdevice.com/api/v5/accounts/redacted/devices', items: [] } [7/8/2020, 21:42:26] [myQ] Throttling myQ API call. Using cached data from the past five seconds. [7/8/2020, 21:42:41] [myQ] { count: 0, href: 'http://api.myqdevice.com/api/v5/accounts/redacted/devices', items: [] } [7/8/2020, 21:42:41] [myQ] Throttling myQ API call. Using cached data from the past five seconds. [7/8/2020, 21:42:56] [myQ] { count: 0, href: 'http://api.myqdevice.com/api/v5/accounts/redacted/devices', items: [] }

and on and on..

markcsegal commented 4 years ago

Realize now.. my doors aren't there. Checked the app and they are gone.. I did reset them the other day to reprogram some remotes, not sure that removed them from the app.. but maybe it did.. Stand by when I get a chance I will readd them.. this might be my issue..

markcsegal commented 4 years ago

Sorry got sidetracked yesterday, so I went and re-added them and they showed up! So likely my bad, but made so many changes including downgrading... so who knows. But I am up and running now!

maelstromchanneled commented 4 years ago

Glad it is working - what version are you running now?

markcsegal commented 4 years ago

Glad it is working - what version are you running now?

2.1.0

hjdhjd commented 4 years ago

All - give v2.1.1 a try, fresh off the presses. Feedback appreciated. Hopefully we got this squashed.

dakotahp commented 4 years ago

@hjdhjd It works beautifully so far and I have high hopes for the long term. Thanks to you and whoever had PRs merged on this release. I don’t have the free time as I used to in order to mess with my setup to help debug.

hjdhjd commented 4 years ago

@hjdhjd This one was yours truly...I just needed to get to the weekend where I had some time :smile: That said...it's always a team effort. There are a few bug fixes queued up in this release and hopefully I've knocked them all out. @LampeMW can you verify 2.1.2 works and close this bug out?

Thanks to all of you guys for reporting bugs and helping with more context to troubleshoot.

Thanks!

maelstromchanneled commented 4 years ago

Camping right now - will try when I return - thanks!

hjdhjd commented 4 years ago

Following up on this one guys - any updates?

justinrhodes commented 4 years ago

v2.1.2 on HomeBridge 1.1.1 has been working fine for me for the past 2 days. No unusual errors in my logs.

BindersFullOfWomen commented 4 years ago

Same. I’ve updated and the errors seem to be fixed.

hjdhjd commented 4 years ago

Closing this one out. Thanks!

dakotahp commented 4 years ago

Still working great!

maelstromchanneled commented 4 years ago

Yep, appears to be working great - thanks!

github-actions[bot] commented 1 year ago

This issue is locked to prevent necroposting on closed issues. Please create a new issue for related support requests, bug reports, or feature suggestions.