naofireblade / homebridge-neato

A Neato vacuum robot plugin for homebridge.
MIT License
69 stars 18 forks source link

Homebridge crashes when map has no zones #42

Closed ifeign closed 5 years ago

ifeign commented 5 years ago

I had to send off my D7 for repair and noticed Homebridge wouldn't start up because the neato plugin was throwing an error due to my vacuum being disconnected.

Is it possible to have this fail more gracefully without affecting other plugins?

homebridge_1  | [8/1/2019, 3:55:08 AM] [NeatoVacuumRobot] error getting boundaries: Error: Request failed with status code 404: undefined
homebridge_1  | [8/1/2019, 3:55:08 AM] [NeatoVacuumRobot] Found robot #1 named "CatBot" with serial "OPS05418-7C3866EF12CA"
homebridge_1  | (node:3593) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
homebridge_1  |     at that.robots.(anonymous function).maps.forEach (/usr/local/lib/node_modules/homebridge-neato/index.js:50:40)
homebridge_1  |     at Array.forEach (<anonymous>)
homebridge_1  |     at /usr/local/lib/node_modules/homebridge-neato/index.js:49:41
homebridge_1  |     at robot.getMapBoundaries (/usr/local/lib/node_modules/homebridge-neato/index.js:110:53)
homebridge_1  |     at /usr/local/lib/node_modules/homebridge-neato/node_modules/node-botvac/lib/robot.js:410:17
homebridge_1  |     at /usr/local/lib/node_modules/homebridge-neato/node_modules/node-botvac/lib/robot.js:482:17
homebridge_1  |     at /usr/local/lib/node_modules/homebridge-neato/node_modules/node-botvac/lib/api.js:34:45
homebridge_1  |     at process._tickCallback (internal/process/next_tick.js:68:7)
homebridge_1  | (node:3593) 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: 3)
homebridge_1  | (node:3593) [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.
homebridge_1  | [8/1/2019, 3:55:08 AM] [NeatoVacuumRobot] Error: Request failed with status code 404: null
naofireblade commented 5 years ago

Hi, do you use plugin version v0.6.2? This looks like an older, already fixed, bug.

ifeign commented 5 years ago

Yes, I'm on 0.6.2. I believe this problem may have derived from the fact that during the repair my robot has been removed from my account. I got it back today and after getting it back on my wifi it works again. I did have e to set up the Homekit accessories again. For some reason even though the name is the same, all my switches loaded in my "default room" instead of where they were meant to be. Going to test after work to see if I can replicate this if I turn off the robot.

dgreif commented 5 years ago

https://github.com/naofireblade/homebridge-neato/blob/master/index.js#L49-L50 is where I was getting an error. I can’t grab the logs at the moment but one of those to arrays way undefined so the forEach threw an error. My Neato got stuck last night and died so it might have been offline even though it was on the charger.

ifeign commented 5 years ago

I had to RMA my Neato again... after restarting Homebridge to update another plugin, this plugin prevents Homebride from starting because it can't find the robot.

homebridge_1  | [8/11/2019, 7:40:28 PM] [NeatoVacuumRobot] Found robot #1 named "Catbot" with serial "OPS05418-7C3866EF12CA"
homebridge_1  | (node:725) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
homebridge_1  |     at that.robots.(anonymous function).maps.forEach (/homebridge/node_modules/homebridge-neato/index.js:50:40)
homebridge_1  |     at Array.forEach (<anonymous>)
homebridge_1  |     at /homebridge/node_modules/homebridge-neato/index.js:49:41
homebridge_1  |     at robot.getMapBoundaries (/homebridge/node_modules/homebridge-neato/index.js:110:53)
homebridge_1  |     at /homebridge/node_modules/homebridge-neato/node_modules/node-botvac/lib/robot.js:410:17
homebridge_1  |     at /homebridge/node_modules/homebridge-neato/node_modules/node-botvac/lib/robot.js:482:17
homebridge_1  |     at /homebridge/node_modules/homebridge-neato/node_modules/node-botvac/lib/api.js:34:45
homebridge_1  |     at process._tickCallback (internal/process/next_tick.js:68:7)
homebridge_1  | (node:725) 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: 2)
homebridge_1  | (node:725) [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.
homebridge_1  | [8/11/2019, 7:40:29 PM] [NeatoVacuumRobot] Error: Request failed with status code 404: null

What's weird is the other plugins continue to load after this, but Homebridge doesn't actually start. I even get snapshots from the Ring plugin, but none of my other accessories respond and the Config UI says that Homebridge is not running.

naofireblade commented 5 years ago

These errors are really hard to fix because parts of the code are rewritten from a PR and I can't test it because my robot has no zone cleaning capability.

I guess I fixed it now. @ifeign @dgreif can you check if it's fixed with v0.6.3?

dgreif commented 5 years ago

@naofireblade I just tested it out and checked the code. All looks good! I confirmed it by pausing wifi to my vacuum on 0.6.2 to reproduce the error, then upgraded and 0.6.3 worked perfectly. Thanks for the fix!

naofireblade commented 5 years ago

Thank you for testing :)