homebridge-tuya-lan icon indicating copy to clipboard operation
homebridge-tuya-lan copied to clipboard

Problem with TuyaLan Discovery - [TuyaLan] Failed to discover ... in time ...

Open posul opened this issue 5 years ago • 39 comments

Hi, Thanks for your work... After successfully homebridge-tuya-lan plugin, I am unable to discover my two smart plugs. I get the error "[3/23/2019, 7:26:45 PM] [TuyaLan] Failed to discover Plug 1 (40525238600194bba1db) in time but will keep looking. [3/23/2019, 7:26:45 PM] [TuyaLan] Failed to discover Plug 2 (40525238600194bb7967) in time but will keep looking." Appreciate any advice you can give. Thanks

My config (keys removed is as follows; { "platform": "TuyaLan", "devices": [ { "name": "Plug 1", "type": "Outlet", "manufacturer": "Brilliant", "model": "Smart WiFi Plug with USB Charger 20676/05", "id": "40525238600194bba1db", "key": "XXXXXXXXXX" }, { "name": "Plug 2", "type": "Outlet", "manufacturer": "Brilliant", "model": "Smart WiFi Plug with USB Charger 20676/05", "id": "40525238600194bb7967", "key": "XXXXXXXXXX" } ] }

posul avatar Mar 23 '19 08:03 posul

are you able to find them with tuya-cli again from the same machine? as it may be a more common problem (for me 2 lightbulbs stopped to appear in HB)

rangerek avatar Mar 26 '19 12:03 rangerek

I'm having this issue too. Still working yesterday but not now. I can still find it via tuya-cli.

haepiyang avatar Mar 29 '19 00:03 haepiyang

I have figured it out that ufw is blocking homebrige from discovering tuya devices. Anyone know which port does tuya api uses to discover devices on network?

haepiyang avatar Mar 29 '19 06:03 haepiyang

Hey, did you work out a fix for this? I've just set up HomeBridge on a Mac for the first time to use with 2 Teckin plugs and get this every time I run HomeBridge.

Nuarton avatar Apr 01 '19 22:04 Nuarton

Hey, did you work out a fix for this? I've just set up HomeBridge on a Mac for the first time to use with 2 Teckin plugs and get this every time I run HomeBridge.

Currently I'm disabling ufw to get it worked.

haepiyang avatar Apr 02 '19 02:04 haepiyang

@posul, this happens when these device don't reply back and that happens because:

  1. network problems (let's hope this is not the case)
  2. Tuya app is open and has a lock on the devices; kill the Tuya app and try restarting Homebridge.

@rangerek, do you still have trouble with 2 devices not showing up?

@haepiyang, the port that is used for discovery is 6666 over UDP. To talk to each device, a TCP connection is made to port 6668 of the device.

@Nuarton, there is a certain firmware version of these Teckin devices that is using a newer form of communication which I haven't been able to decode yet. I havn't been able to source one locally to figure out the problem.

AMoo-Miki avatar Apr 08 '19 10:04 AMoo-Miki

I'm having the same errors as others. I'm using this device: https://www.brilliantsmart.com.au/smart-products/electrical/wifi-plug-with-usb-charger/

Same error: Fails to discover..... I don't have a firewall installed on my home bridge server.

9SL9 avatar Apr 10 '19 11:04 9SL9

Hi, I've update firmware of two Teckin outlets and now Hombridge not discover the devices.. same error. solution?

Thanks.

rcapolino avatar Apr 11 '19 12:04 rcapolino

@rcapolino there’s some kind of issue with the new firmware on the Teckin plugs. I think fix is being worked on, it’ll be worth keeping an eye on this thread: https://github.com/AMoo-Miki/homebridge-tuya-lan/issues/23

Nuarton avatar Apr 11 '19 14:04 Nuarton

@rcapolino there’s some kind of issue with the new firmware on the Teckin plugs. I think fix is being worked on, it’ll be worth keeping an eye on this thread: #23

Thanks..

rcapolino avatar Apr 11 '19 14:04 rcapolino

What about the brilliant plugs?

9SL9 avatar Apr 11 '19 19:04 9SL9

Some devices don't respond to discovery. Alter your config for the device by adding `"ip": "<the IP of the device>"; this will tell the plugin to ignore the fact that it didn't discover the device on its own and try to connect using the IP. Lemme know if that solves the problem for you.

AMoo-Miki avatar Apr 18 '19 10:04 AMoo-Miki

Some devices don't respond to discovery. Alter your config for the device by adding `"ip": ""; this will tell the plugin to ignore the fact that it didn't discover the device on its own and try to connect using the IP. Lemme know if that solves the problem for you.

Unfortunately not. I added in "ip": "192.168.0.48" but there is no console feedback that indicates it's tried to connect direct to the IP. And eventually I still get the failed to discover message.

9SL9 avatar Apr 18 '19 11:04 9SL9

Hi,

First off, thank you so much for your hard work I use your plugin for two light switches and it works perfectly.

Unfortunately I recently purchased a dimmer switch, pulled the latest (which I think supports dimmer switches, not dimmer bulbs) and am experiencing the same discovery issue noted above. I read through this thread and added the ip property to my device config but then I get the following error:

Config:

{
        "name": "Light",
        "type": "SimpleDimmer",
        "manufacturer": "OITTM",
        "model": "Dimmer Switch",
        "id": "55430317b4e62d6590a1",
        "key": "xxxxxxxxxxxxxx",
        "ip": "10.0.0.53"
}

Error:

[TuyaLan] Failed to discover Light (55430317b4e62d6590a1) in time but will connect via 10.0.0.53.
[TuyaLan] Connected to Light
[TuyaAccessory] Socket had a problem and will reconnect to Light (Error: ERR_PING_TIMED_OUT)
[TuyaAccessory] Closed connection with Light

I've tried changing the type to SimpleLight as well just to see if I could get it working but run into the same errors. I am able to ping the device ip successfully from my homebridge server via ping 10.0.0.53

Any suggestions would be much appreciated

ryan86 avatar Apr 19 '19 05:04 ryan86

Just a little extra information for mine: port 6668 is open: nc -zv 192.168.0.48 6667-6669 nc: connect to 192.168.0.48 port 6667 (tcp) failed: Connection refused Connection to 192.168.0.48 6668 port [tcp/*] succeeded! nc: connect to 192.168.0.48 port 6669 (tcp) failed: Connection refused

9SL9 avatar Apr 24 '19 20:04 9SL9

Same problem here. I'm trying to connect the following outlet to HB: https://www.dx.com/p/smart-socket-eu-power-plug-wifi-smart-plug-mobile-app-remote-control-usb-output-works-with-amazon-alexa-google-home-j15-eu-plug-white-2077653#.XMNPQZMzamk

Tried adding the "ip" option in the config.json of homebridge, when I discovered this option is not being used in the npm version of homebridge-tuya-lan, so I replaced it with the latest commit (#8088d86)

{ "name": "Plug 1", "type": "Outlet", "manufacturer": "BVA", "model": "Smart Wifi Plug", "ip": "192.168.1.129", "id": "23042036b4e62d578fc4", "key": "XXXXXXXXXXXX" },

The outlets I'm using only have port 6668 open:

Starting Nmap 7.70 ( https://nmap.org ) at 2019-04-26 19:45 CEST Nmap scan report for ESP_578FC4 (192.168.1.129) Host is up (0.0036s latency). Not shown: 999 closed ports PORT STATE SERVICE 6668/tcp open irc

Nmap done: 1 IP address (1 host up) scanned in 7.65 seconds

It will show up in HomeKit this way, but it doesn't work, keep getting the following error:

4/26/2019, 6:26:01 PM] [TuyaLan] Connected to Plug 1

[TuyaAccessory] Socket had a problem and will reconnect to Plug 1 (EPIPE)

[TuyaAccessory] Closed connection with Plug 1

[TuyaAccessory] Odd message from Plug 1 with command 8: { cmd: 8, data: 'í;¶\u001a´Q!¬È*°¨ÑßY²' }

[TuyaAccessory] Odd message from Plug 1 with command 8: { cmd: 8, data: 'í;¶\u001a´Q!¬È*°¨ÑßY²' }

[TuyaAccessory] Socket had a problem and will reconnect to Plug 1 (Error: ERR_PING_TIMED_OUT)

[TuyaAccessory] Closed connection with Plug 1

NickB23 avatar Apr 26 '19 18:04 NickB23

@NickB23 Yeah, it is exactly the same for me – whilst using some Teckin outlets.

@AMoo-Miki Please do tell me if there is anything I can do to help you resolve this.

JappJappJapp avatar Apr 26 '19 19:04 JappJappJapp

Same problem here. I'm trying to connect the following outlet to HB: https://www.dx.com/p/smart-socket-eu-power-plug-wifi-smart-plug-mobile-app-remote-control-usb-output-works-with-amazon-alexa-google-home-j15-eu-plug-white-2077653#.XMNPQZMzamk

Tried adding the "ip" option in the config.json of homebridge, when I discovered this option is not being used in the npm version of homebridge-tuya-lan, so I replaced it with the latest commit (#8088d86)

What command did you use to install the latest commit?

9SL9 avatar Apr 26 '19 21:04 9SL9

@9SL9 I think I used this one:

sudo npm install -g git+https://github.com/AMoo-Miki/homebridge-tuya-lan.git

JappJappJapp avatar Apr 26 '19 21:04 JappJappJapp

Thanks that worked. I'm getting the same errors as you guy's (Error: ERR_PING_TIMED_OUT)

9SL9 avatar Apr 27 '19 00:04 9SL9

@NickB23 Yeah, it is exactly the same for me – whilst using some Teckin outlets.

@AMoo-Miki Please do tell me if there is anything I can do to help you resolve this.

@AMoo-Miki Yes me too! Let me know if I can do anything. I'd be happy to help :-)

NickB23 avatar Apr 28 '19 11:04 NickB23

@9SL9, @ryan86: ERR_PING_TIMED_OUT happens when the device doesn't reply to my checking if the connection is alive. I have a feeling that yours are not; let's test this and see.

Locate the plugin installation location; on my RPi, it is /var/lib/npm/lib/node_modules/homebridge-tuya-lan. Edit the file lib\TuyaAccessory.js and comment out line 90 this._socket._ping(); by adding // to the beginning of the line. Restart homebridge and see if you can control your device.

If you can't find the file, lemme know and I will think of something else.

@NickB23: your device is using a different mode of encryption. I will need to get my hands on one of these devices to be able to figure them out.

AMoo-Miki avatar Apr 28 '19 22:04 AMoo-Miki

@AMoo-Miki Found the file and commented out ln 90, restarted homebridge.

Log:

[TuyaLan] Failed to discover Light (55430317b4e62d6590a1) in time but will connect via 10.0.0.53.
[TuyaLan] Connected to Light

Light shows up in accessories even shows up in the home app, but with 'No Response' and I can click it, but it does not control the light.

Here is the light by the way.

ryan86 avatar Apr 30 '19 01:04 ryan86

Hey,

i just tested your solutions to get my Switch working. The Switch is not reacting, since there is a Problem with a reconnection like this:

[2019-5-4 01:37:34] [TuyaLan] Failed to discover Wohnzimmer (73675161cc50e346b170) in time but will connect via 192.168.178.35. [2019-5-4 01:37:34] [TuyaLan] Connected to Wohnzimmer [TuyaAccessory] Socket had a problem and will reconnect to Wohnzimmer (ECONNRESET)

While homebridge tries to reconnect to the switch, i just used the Tuya App to switch the Lights on and off and got this messages in homebridge console:

[TuyaAccessory] Odd message from Wohnzimmer with command 8: { cmd: 8, data: '²^ö\u0006Ýâ>lûá@ W’¢H' } [TuyaAccessory] Odd message from Wohnzimmer with command 8: { cmd: 8, data: ',ÄjMöôwô\u000e¨>4ELI' } [TuyaAccessory] Odd message from Wohnzimmer with command 8: { cmd: 8, data: 'dÿǦ£ƒAٜJ‹\u0003¥]\u0001è' } m and will reconnect to Wohnzimmer (ECONNRESET) [TuyaAccessory] Closed connection with Wohnzimmer [TuyaAccessory] Odd message from Wohnzimmer with command 8: { cmd: 8, data: 'g\u0001²uL,!\u0015Ðé*ÂÜX\fc' }

I got this Switch:

https://www.amazon.de/JinvooSmart-Smart-Switch-Compatiable-Google/dp/B078GM4D39/ref=sr_1_fkmrnull_6?__mk_de_DE=ÅMÅŽÕÑ&crid=20XSS3WYEG0HS&keywords=jinvoo+smart+lichtschalter&qid=1556927138&s=gateway&sprefix=jinvoo+smart+%2Caps%2C153&sr=8-6-fkmrnull

Any Ideas?

alp-can avatar May 03 '19 23:05 alp-can

I updated the first switch by mistake. When you use the old firmware with the Tuya-Lan Plugin everthing's fine! I just tested it successfully with another switch :-) I have some reconnects and i don't know why.. it does not affect the switch, it reacts to every command.

[TuyaAccessory] Socket had a problem and will reconnect to Wohnzimmer (ECONNRESET) [TuyaAccessory] Closed connection with Wohnzimmer [TuyaAccessory] Socket had a problem and will reconnect to Wohnzimmer (ECONNRESET) [TuyaAccessory] Closed connection with Wohnzimmer [TuyaAccessory] Sending Wohnzimmer {"1":true} [TuyaAccessory] SimpleLight changed: {"1":true} [TuyaAccessory] Sending Wohnzimmer {"1":false} [TuyaAccessory] SimpleLight changed: {"1":false}

alp-can avatar May 04 '19 14:05 alp-can

I had to reinstall Homebridge jail on my FreeNAS and have the same problem with 11.2 jail (I suspect some changes in network stack in iocage) So IP entry made the trick - great :) But for 2 bulbs that updated it ends with ECONNRESET - any chances it is fixed (or update breaks the api)?

rangerek avatar May 17 '19 19:05 rangerek

Any update on this? Just bought 4 plugs today and upgraded the firmware straight away...

sylwester- avatar May 24 '19 18:05 sylwester-

Today I bought 2x smart outlets (https://www.brilliantsmart.com.au/smart-products/electrical/wifi-plug-with-usb-charger/).

One is working great- I'm so impressed with the plugin in, thank you! :)

But the second one is running the latest firmware, and doesn't work. I'm getting the same errors as above, see below.

Any updates on how to fix this?

[5/30/2019, 10:07:00 PM] [TuyaLan] Starting discovery... [5/30/2019, 10:07:00 PM] Homebridge is running on port 51826. [TuyaAccessory] Discovery started. [5/30/2019, 10:07:03 PM] [TuyaLan] Discovered Porch Lights (04761182600194b8e913) [5/30/2019, 10:07:03 PM] [TuyaLan] Connected to Porch Lights [5/30/2019, 10:07:03 PM] [TuyaLan] Ready to handle Porch Lights with signature {"1":true} [TuyaAccessory] Sending Porch Lights {"1":false} [TuyaAccessory] Sending Porch Lights {"1":true} [5/30/2019, 10:08:00 PM] [TuyaLan] Failed to discover Backyard Lights (88138834600194cb1089) in time but will connect via 192.168.86.61. [5/30/2019, 10:08:00 PM] [TuyaLan] Connected to Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET) [TuyaAccessory] Closed connection with Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET) [TuyaAccessory] Closed connection with Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET) [TuyaAccessory] Closed connection with Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET) [TuyaAccessory] Closed connection with Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET) [TuyaAccessory] Closed connection with Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET) [TuyaAccessory] Closed connection with Backyard Lights [TuyaAccessory] Socket had a problem and will reconnect to Backyard Lights (ECONNRESET)

fergburg avatar May 30 '19 13:05 fergburg

Is there any update on this as I was hoping to buy some of the Brilliant Smart Plugs

TheHomekitWayFinder avatar Jun 01 '19 09:06 TheHomekitWayFinder

Unfortunately no recent response to any posts on this issue from the repo owner. Perhaps this is the end of the line for this functionality now that the Tuya firmware’s have broken connectivity.

9SL9 avatar Jun 01 '19 21:06 9SL9