codetheweb / homebridge-tuya-outlet

A plugin for Homebridge for Tuya-based outlets
15 stars 11 forks source link

Plugin doesn't work unless all accessories are plugged up #14

Closed ldhall1856 closed 6 years ago

ldhall1856 commented 6 years ago

I was able to get this plugin to work with all of my outlets but if i disconnect one of them it crashes homebridge.

Error below:

/usr/lib/node_modules/homebridge-tuya-outlet/node_modules/tuyapi/index.js:282 client.write(buffer); ^

TypeError: Cannot read property 'write' of null at retryConnect.to (/usr/lib/node_modules/homebridge-tuya-outlet/node_modules/tuyapi/index.js:282:14) at Socket.handleError (/usr/lib/node_modules/homebridge-tuya-outlet/node_modules/net-retry-connect/index.js:21:13) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

tomky commented 6 years ago

This is a critical issue. If one of the outlet is not online, a whole home bridge will be unresponsive to any further command to any other platform or accessory. It just stuck.

I think you can add a timeout for the command and status query to the outlet. When the request timeout, you may just set the status of the outlet as not available or something so we know the outlet is dead, but keep homebridge alive?

codetheweb commented 6 years ago

I'm currently otherwise occupied and won't get to this for about a week. But feel free to open a PR with your changes :).

toooooobi commented 6 years ago

Hi,

I love your plugin! But it crashes the whole homebridge when one device is not online anymore. Would you please fix this issue? Thank you!

codetheweb commented 6 years ago

Thanks for the reminder.

I'll try to get to it sometime next week.

codetheweb commented 6 years ago

@ldhall1856 @tomky @toooooobi I've published a new package that fixes many issues, including making Homebridge crash if your device isn't plugged in. It also includes an easier setup process.

Please move to homebridge-tuya instead of continuing to use this package.