iRayanKhan / homebridge-tuya

A Homebridge plugin to control Tuya devices locally.
MIT License
395 stars 165 forks source link

ERR PING TIME OUT #443

Closed jakekoh closed 5 months ago

jakekoh commented 8 months ago

I have a few of those "Smart wifi tuya branded sockets" on Tuya IoT platform those being classified as "Smart Sockets" i have not issues adding them to the plugin, but those that are classified as "Smart Plug" keeps returning with "(Error: ERR_PING_TIMED_OUT)"

To Reproduce Steps to reproduce the behavior:

I'm using homebridge-tuya-local v3.0.5

i've tried changing the types/dpPower on the plugin level but no luck with any.

soxrok2212 commented 8 months ago

Facing the same issue here on my RGB light bulbs

05TEVE commented 8 months ago

I have a few of those "Smart wifi tuya branded sockets" on Tuya IoT platform those being classified as "Smart Sockets" i have not issues adding them to the plugin, but those that are classified as "Smart Plug" keeps returning with "(Error: ERR_PING_TIMED_OUT)"

To Reproduce Steps to reproduce the behavior:

I'm using homebridge-tuya-local v3.0.5

i've tried changing the types/dpPower on the plugin level but no luck with any.

Hi, are you able to try with this version of the plugin. Looking at the version, this one appears to be the fork of it found at https://github.com/ayushsharma82/homebridge-tuya-local.

As for the issues that you are seeing that sounds like a network connection issue to me. Is the host where homebridge is running able to reach the devices via ping?

jakekoh commented 8 months ago

I have a few of those "Smart wifi tuya branded sockets" on Tuya IoT platform those being classified as "Smart Sockets" i have not issues adding them to the plugin, but those that are classified as "Smart Plug" keeps returning with "(Error: ERR_PING_TIMED_OUT)" To Reproduce Steps to reproduce the behavior: I'm using homebridge-tuya-local v3.0.5 i've tried changing the types/dpPower on the plugin level but no luck with any.

Hi, are you able to try with this version of the plugin. Looking at the version, this one appears to be the fork of it found at https://github.com/ayushsharma82/homebridge-tuya-local.

As for the issues that you are seeing that sounds like a network connection issue to me. Is the host where homebridge is running able to reach the devices via ping?

did that, i'm now using 3.1.0 from this repo. other than the new IP field i still can't get that 2 devices connected. both devices can still be controlled by smart life app while it kept throwing ERR_PING_TIMED_OUT on homebridge.

FGarridoV commented 7 months ago

I had duplicated this issue. I just closed the duplicated issue. I am experiencing the same issue. Here are the details of my mine, that seem is the same as this one.

I checked the ping from the hombridge and it is reachable.

--- My original report ---

Checklist

Before to read First of all, thank you for maintaining this repo. It is very useful and easy to set up. I was using it for some years, without issues. I have many lightbulbs that use Tuya and everything works perfect with this plugin. Now, for the first time I am experiencing an issue. After hours of trying, I couldn't solve. I tried with the latest plugin version and the beta version.

Describe the bug I bought a new smart plug/outlet that also use Tuya but I cannot interact with it. I installed this device as usual and I set a fixed IP for this device using its MAC address (Static DHCP in my router). The homebridge logs shows: "Error: ERR_PING_TIMED_OUT". The logs shown (related to this device) are:

[25/02/2024, 11:18:04] [TuyaLan] Discovery - Discovery started on port 6666.
[25/02/2024, 11:18:04] [TuyaLan] Discovery - Discovery started on port 6667.
[25/02/2024, 11:18:08] [TuyaLan] Discovered Outlet1 (bf5b97e7286e**********) identified as Outlet (3.4)
[25/02/2024, 11:18:08] [TuyaLan] Accessory IP changed from undefined to 192.168.1.30
[25/02/2024, 11:18:08] [TuyaLan] Discovery ended.
[25/02/2024, 11:18:08] [TuyaLan] Connected to Outlet1
[25/02/2024, 11:18:08] [TuyaLan] Disconnected from Outlet1
[25/02/2024, 11:18:44] [TuyaLan] Socket had a problem and will reconnect to Outlet1 (Error: ERR_PING_TIMED_OUT)
[25/02/2024, 11:18:49] [TuyaLan] Disconnected from Outlet1

To Reproduce I set up this device in the same way I set up my lights using the following json:

{
    "name": "Outlet1",
    "type": "Outlet",
    "manufacturer": "EZH",
    "model": "Wifi Mini Smart Life Outlet",
    "id": "bf5b97e7286e**********",
    "key": "yt}C.S**********",
    "ip": "192.168.1.30",
    "voltsId": 9,
    "ampsId": 8,
    "wattsId": 7,
    "voltsDivisor": 10,
    "ampsDivisor": 1000,
    "wattsDivisor": 10,
    "dpPower": 1
}

The output I got from the iot.tuya API was:

{
  "result": {
    "active_time": 1708175200,
    "bind_space_id": "5121****”,
    "category": "cz",
    "create_time": 1708175200,
    "custom_name": "Outlet1",
    "icon": "smart/icon/ay1541056239985fDGjj/9c8600f63f144d075b461f01b0e93873.png",
    "id": "bf5b97e7286ec5bd5dshsb",
    "ip": “***.***.***.***”,
    "is_online": true,
    "lat": "52.0000",
    "local_key": "yt}C.S**********”,
    "lon": "4.3500",
    "model": "5225000200",
    "name": "LSC Smart Power Plug",
    "product_id": "jrsr2b**********”,
    "product_name": "LSC Power Plug w/ Power Meter EU",
    "sub": false,
    "time_zone": "+01:00",
    "update_time": 1708852756,
    "uuid": "49f633**********”
  }

Expected behavior I would like to turn on and off the plug using homebridge. I cannot do it from neither from homebridge and home app. I CAN control it using Tuya Smart App.

Screenshots

Environment (please complete the following information):

Additional context Here is the link of the product I am using: https://www.action.com/nl-nl/p/3202087/lsc-smart-connect-slimme-stekker/

drheck commented 7 months ago

Same here with 4 new Antela devices. The older ones have no problems. I have tried some other tuya plugins, but these are using the same libraries....

sdekker90 commented 6 months ago

I am having the same issue with LSC Smart Connect outdoor up/down lights.

05TEVE commented 6 months ago

Hi, I am unable to replicate the issue on my side here. However i am noticing a trend that this is mainly impacting new devices. I think this may be related a combination of the Tuya 3.4 protocol change and the local keys potentially not being handled correctly.

Can you confirm whether all of the failing devices have "Discovered DEVICE NAME (BLAH) identified as Outlet (3.4)" in them?

05TEVE commented 6 months ago

Right now it looks like on my network i only have devices with the 3.3 Tuya protocol.

sdekker90 commented 6 months ago

You are right! It is a Tuya v3.4 protocol device.

[15/03/2024, 08:42:08] [TuyaLan] Discovered Gasten (****) identified as RGBTWLight (3.4) [15/03/2024, 08:42:08] [TuyaLan] Connected to Gasten [15/03/2024, 08:42:08] [TuyaLan] Disconnected from Gasten [15/03/2024, 08:42:44] [TuyaLan] Socket had a problem and will reconnect to Gasten (Error: ERR_PING_TIMED_OUT) [15/03/2024, 08:42:49] [TuyaLan] Disconnected from Gasten

Is there anything I can do to help fix this issue?

Environment (please complete the following information):

ogunDecode commented 6 months ago

I'm having the same issues.

[3/22/2024, 12:49:08 AM] [TuyaLan] Discovered Light (id) identified as RGBTWLight (3.4) [3/22/2024, 12:49:08 AM] [TuyaLan] Discovery ended. [3/22/2024, 12:49:08 AM] [TuyaLan] Connected to Light [3/22/2024, 12:49:08 AM] [TuyaLan] Disconnected from Light [3/22/2024, 12:49:44 AM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_PING_TIMED_OUT) [3/22/2024, 12:49:50 AM] [TuyaLan] Disconnected from Light [3/22/2024, 12:50:25 AM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_PING_TIMED_OUT)

05TEVE commented 6 months ago

Refer

The more i look at this, the more i think it is related to the 3.4 protocol. To fix it, I believe we need to re-write the msgHandler for the 3.4 devices (https://github.com/iRayanKhan/homebridge-tuya/blob/main/lib/TuyaAccessory.js#L277). The same change will also need to be done for the 3.5 protocol as that one breaks even worse than the 3.4 accessories (does not even recognise the device in discovery).

This has been solved in the tiny-tuya project with python, but i haven't had time to go through and attempt the same in this project. https://github.com/harryzz/tuyapi/commit/ef4473b4679c29d07ae504490503b6fa87d3e733

If anyone has time to try and implement this that would be amazing! I am sure there is a solution for this and the 3.5 protocol updates, but it will take time to implement and test.

tomash1 commented 6 months ago

@05TEVE Hi first of all i would like to ask for understanding as this is my first contribution to open source project, so there can be a lot of PR etc. mistakes :)

I was able to prepare changes based on https://github.com/harryzz/tuyapi/commit/ef4473b4679c29d07ae504490503b6fa87d3e733

My 3.4 LED strip controller now is connected correctly and HomeKit is able to control this device.

Here are my changes with 3.4 support: https://github.com/iRayanKhan/homebridge-tuya/pull/455

05TEVE commented 6 months ago

Awesome! Let me add these into the 3.1.1 release and get a beta out for wider testing!

05TEVE commented 6 months ago

I have pushed live 3.1.1-beta.12 with the changes contributed by @tomash1!

The changes look good with the existing devices i have, but further testing from everyone on this thread would be great!

sdekker90 commented 6 months ago

Thank you both for the work on this. Just installed 3.1.1-beta.12. The device now shows up as an RGB light in Apple Homekit. With 3.1.1.beta-9 it showed up as a light with only on/off options, no brightness or colour control. It does however not react to controlling it. One thing that is being logged in HomeBridge is the following:

[02/04/2024, 20:11:45] [homebridge-tuya] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.

It is also still loggin "ERR_PING_TIMED_OUT', except now without "Connected to device_id"

[02/04/2024, 19:20:50] [TuyaLan] Disconnected from device_id [02/04/2024, 19:21:04] [TuyaLan] Socket had a problem and will reconnect to device_id (Error: ERR_PING_TIMED_OUT)

tomash1 commented 6 months ago

@sdekker90 make sure that you configured DPS map for your device. Updated values are probably also 3.4 protocol related but this is more or less device configuration. For me these values works (it can be configured in homebridge UI or just JSON configuration): "dpPower": 20, "dpBrightness": 22, "dpColorTemperature": 23, "dpMode": 21, "dpColor": 24,

ogunDecode commented 5 months ago

Thank you for the fix, it works great, but I'm experiencing a few issues. There were a few times today when the light flashed for a second, and another time when the brightness suddenly dropped. I'm not sure what's causing this.

Logs when light flashed:

[4/5/2024, 11:38:31 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_PING_TIMED_OUT)
[4/5/2024, 11:38:46 PM] [TuyaLan] Socket had a problem and will reconnect to Light (EHOSTUNREACH)
[4/5/2024, 11:38:54 PM] [TuyaLan] Socket had a problem and will reconnect to Light (EHOSTUNREACH)
[4/5/2024, 11:39:06 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_CONNECTION_TIMED_OUT)
[4/5/2024, 11:39:21 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_CONNECTION_TIMED_OUT)
[4/6/2024, 2:13:50 AM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_PING_TIMED_OUT)

Logs when the brightnes changed on it's own:

[4/6/2024, 9:03:58 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_PING_TIMED_OUT)
[4/6/2024, 9:04:06 PM] [TuyaLan] Socket had a problem and will reconnect to Light (EHOSTUNREACH)
[4/6/2024, 9:04:14 PM] [TuyaLan] Socket had a problem and will reconnect to Light (EHOSTUNREACH)
[4/6/2024, 9:04:22 PM] [TuyaLan] Socket had a problem and will reconnect to Light (EHOSTUNREACH)
[4/6/2024, 9:04:31 PM] [TuyaLan] Socket had a problem and will reconnect to Light (EHOSTUNREACH)
[4/6/2024, 9:04:33 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_CONNECTION_TIMED_OUT)
[4/6/2024, 9:04:37 PM] [TuyaLan] Malformed message from Light with command 16: <Buffer 6a 73 6f 6e 20 6f 62 6a 20 64 61 74 61 20 75 6e 76 61 6c 69 64>
[4/6/2024, 9:04:37 PM] [TuyaLan] Raw message from Light (3.4) with command 16: 000055aa0000cc3f0000001000000048000000019583499c8df719f77114581434f041e25edad515cecfb88068649341a740bc239725e18cfb4766f3394137a58d72d9984e05717437c870237deb7b558aa2bd1e0000aa55
[4/6/2024, 9:04:41 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_CONNECTION_TIMED_OUT)
[4/6/2024, 9:04:49 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_CONNECTION_TIMED_OUT)
[4/6/2024, 9:04:57 PM] [TuyaLan] Socket had a problem and will reconnect to Light (Error: ERR_CONNECTION_TIMED_OUT)
FGarridoV commented 5 months ago

Thank you from my side as well. The issue is solved using the beta! Thanks @05TEVE @tomash1

05TEVE commented 5 months ago

This is now released as part of the 3.1.1 release. Closing as resolved.

soxrok2212 commented 1 month ago

I've got a couple Lumary lights that are facing this issue, even on 3.1.1:

[8/5/2024, 11:48:20 PM] [homebridge-tuya] Socket had a problem and will reconnect to bar light right (Error: ERR_PING_TIMED_OUT)
[8/5/2024, 11:48:25 PM] [homebridge-tuya] Disconnected from bar light right

Tested pinging manually which works as expected, and can reach port 6668.

soxrok2212 commented 1 month ago

I've got a couple Lumary lights that are facing this issue, even on 3.1.1:

[8/5/2024, 11:48:20 PM] [homebridge-tuya] Socket had a problem and will reconnect to bar light right (Error: ERR_PING_TIMED_OUT)
[8/5/2024, 11:48:25 PM] [homebridge-tuya] Disconnected from bar light right

Tested pinging manually which works as expected, and can reach port 6668.

Update: turns out this was due to my VLANs. I have my lan on br.1 and IOT on br.20. I had to open port 6667/udp from the IOT VLAN to the router, then set up a udp broadcast relay. Works well now :)

Hedrakk commented 2 weeks ago

I've got a couple Lumary lights that are facing this issue, even on 3.1.1:

[8/5/2024, 11:48:20 PM] [homebridge-tuya] Socket had a problem and will reconnect to bar light right (Error: ERR_PING_TIMED_OUT)
[8/5/2024, 11:48:25 PM] [homebridge-tuya] Disconnected from bar light right

Tested pinging manually which works as expected, and can reach port 6668.

Update: turns out this was due to my VLANs. I have my lan on br.1 and IOT on br.20. I had to open port 6667/udp from the IOT VLAN to the router, then set up a udp broadcast relay. Works well now :)

Hi @soxrok2212

I'm having the same issues but I'm kind of new to all this. Can you explain what you did to solve the issue in more details, I would and probably others like me, would really appreciate this.

Thank you.

soxrok2212 commented 2 weeks ago

Yeah, so on OpenWrt I have my LAN (where my homebridge container resides) on vlan 1 and firewall zone "lan". My IoT devices are on vlan 20 in the firewall zone "iot".

First, I created a UDP relay in /etc/rc.local. This relay runs on the router itself.

udp-broadcast-relay-redux --id 1 --port 6667 --dev br.20 --dev br.1 -f

Then, I created a firewall rule to allow traffic from the IoT vlan into the router on port 6667/udp. udp-broadcast-relay-redux then forwards this traffic to br.1.

config rule
    option name 'iot-router-allow-6667'
    list proto 'udp'
    option src 'iot'
    option dest_port '6667'
    option target 'ACCEPT'
Hedrakk commented 2 weeks ago

Yeah, so on OpenWrt I have my LAN (where my homebridge container resides) on vlan 1 and firewall zone "lan". My IoT devices are on vlan 20 in the firewall zone "iot".

First, I created a UDP relay in /etc/rc.local. This relay runs on the router itself.

udp-broadcast-relay-redux --id 1 --port 6667 --dev br.20 --dev br.1 -f

Then, I created a firewall rule to allow traffic from the IoT vlan into the router on port 6667/udp. udp-broadcast-relay-redux then forwards this traffic to br.1.

config rule
  option name 'iot-router-allow-6667'
  list proto 'udp'
  option src 'iot'
  option dest_port '6667'
  option target 'ACCEPT'

@soxrok2212 Hum... I don't know how this would translate to my situation. On my side, everything is on a single Eero mesh router. My old tuya switches are working fine, but the newer ones (purchased in 2024) aren't working with this Homebridge plugin.

Thanks for the details.