codetheweb / homebridge-tuya-outlet

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

Keep getting Connection Refused error #2

Closed a2ron44 closed 6 years ago

a2ron44 commented 6 years ago

I keep getting a connection refused error when I start homebridge. I get this error ever second or so. I sniffed out the parameters using Charles and cannot get my devices to connect in homebridge. They work just fine on Alexa or my phone

{ Error: connect ECONNREFUSED [myIP]:6668 at Object.exports._errnoException (util.js:1022:11) at exports._exceptionWithHostPort (util.js:1045:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '[myIP]', port: 6668 }

I'm using a config that looks like: { "accessory": "TuyaOutlet", "name": "Lampy", "ip": "[myIP]", "devId": "012002662c3ae84694d8", "uid": "xRLBlgDAoYJP2Edx", "localKey": "930fc2c2731272ac" }

Does this config look correct? Or am I putting the wrong IDs in the fields?

codetheweb commented 6 years ago

First, if you haven't already, please remove and add back your device so that the key changes. Otherwise other people will be able to control your device and potentially see information about your network, depending on how detailed Tuya's Cloud API is.

With that aside, your parameters look right except the UID. It's not actually required, so either take it out completely or replace xRLBlgDAoYJP2Edx with 11111111111111111111.

a2ron44 commented 6 years ago

ok, thanks for the advice on security. I removed the UID and it's still refused. Maybe I'll try to reset and sniff out again. Per the instructions, I never did see that line in Charles where "a=s.m.dev.list". I did see one that listed devices though.

a2ron44 commented 6 years ago

I have to call this add-on broken, at least for me. Followed directions for finding the parameters and connection is always refused. Is it possible Alexa is messing with this? (I already had this connected from the other day).

codetheweb commented 6 years ago

Yes, quite possible. The outlet will only accept one TCP connection at a time. Try unplugging Alexa and Google Home if you have one (also, please make sure the app is closed on your phone).

a2ron44 commented 6 years ago

So, does homebridge keep the connection alive the entire time? Or will I be able to use this plugin along with Alexa? Really would like to use both controllers as they are in different areas of my house.

codetheweb commented 6 years ago

It currently keeps the connection alive the whole time. Tuya's API is pretty unreliable. I might change that in the future, I'm planning to run some tests to see if attempting to keeping the connection open actually helps at all.

codetheweb commented 6 years ago

Closing as TuyAPI now only opens a socket to the device when necessary.