xZetsubou/hass-localtuya

Device becomes unconnectable until it is rebooted

Opened this issue · 34 comments

LocalTuya Version

2024.6.0

Home Assistant Version

2024.7.1

Environment

  • Does the device work using the Home Assistant Tuya Cloud component?
  • Is this device connected to another local integration, including Home Assistant and any other tools?
  • The devices are within the same HA subnet, and they get discovered automatically when I add them

What happened?

I'm starting to use Local Tuya integration and I've already identified at least 2 devices that disconnect for no apparent reason (1 dimmer switch and 1 IR remote control). Even disconnected from Local Tuya, they work normally in the Tuya Cloud integration. To get the devices working again (at least for a while) I need to unplug them and plug them to the power.

Steps to reproduce.

the problem occurs randomly

Relevant log output

No response

Diagnostics information.

localtuya-c66281edf107979133eaa22f6a3217d8-IR escri-173b10c3457ca32d08831de53cd0f4f7.json
localtuya-c66281edf107979133eaa22f6a3217d8-D2moes-92d372c4595d286a2010608913313466.json

Can you test the master version and see if there's any improvements

Install Master Version

Go HACS -> Local Tuya -> On top right corner click on the ⋮ and choose redownload and select master

image

And restart HA then re-add your device

Ensure that the connection is stable between Home Assistant and the device it self you could ping to the device for sometime to test it, the cloud will works as long the device reach the internet unlike local need to have stability connection for both device and home assistant with the routers.

Hi!
How do I know if I installed the master version?
As soon as I select the “master” version, the “2024.6.0” version reappears on the screen even before I click the “download” button. Is that how it really works?
Capture

I have the same issue with two Feit dimmer switches.

Logger: custom_components.localtuya.coordinator
Source: custom_components/localtuya/core/pytuya/init.py:298
integration: LocalTuya (documentation, issues)
First occurred: 18:25:26 (11 occurrences)
Last logged: 18:26:00

[011...19c - Dining Room ] Failed to connect to 192.168.50.237: [Errno 104] Connect call failed ('192.168.50.237', 6668)
[801...2c7 - Kitchen Table] Disconnected: waiting for discovery broadcast
[801...2c7 - Kitchen Table] Failed to connect to 192.168.50.238: [Errno 104] Connect call failed ('192.168.50.238', 6668)
[011...19c - Dining Room ] Disconnected: waiting for discovery broadcast

They were working fine with the original loca tuya.

If reinstallation of LocalTuya I did was correct (as I mentioned above), then the issues continues. This issue occurs with dimmers, IR transmitters, and some smart plugs.

HACS has a bug sometimes that If you select master it's actually reject and revert to old version, either way I'll push new update soon if the bug remains keep in mind that with new changes the devices needs to reboot "from the power" then it should at least be stabilized and reconnect better.

Just confirming I'm also having the same issue with 3 if 9 of my tuya devices. All available in the app, but 3 not available in the integration. Integration doesn't see any new devices to add, also rebooting the dimmer switch doesn't help me

Some more strange data points to this issue. I found that the two mentioned devices intermittently reconnect and drop out again. And while they work flawlessly in the Tuya Smart app, they are the only two devices that produce a "Network Error" when I perform a "Check Device Network" in the Tuya app (click on the device, then the "edit" button in the top right corner, then "Check Device Network".

Does the losing connection behavior still occurs in 2024.7.0 update? I'm kinda sure this isn't and not sure if it fixable since it more like network issue then integration issue

Yes, no change. I agree that it is a strange issue but, again, it was working flawlessly for months in the original Local Tuya integration.
I also deleted both (original and fork) and then reinstalled the fork only. And, like others have mentioned, then it can't find those two items as well as two others in the configuration ("...no datapoints found"). Also tried to switch from standard to DP instruction set in the TUYA IOT platform. Made no difference.

Same issue remains in 2024.7.0. The devices disconnect and reconnect from time to time.

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

The issue is still present.

The problem persists. Is @xZetsubou trying any solution for this?

same here

Yeah super odd behavior. It's the same switches too, only 2 of my I don't work, but it's always the same 2. All 8 work fine in the tuya app though. I've power cycled the switches, nothing helps.

Can you give more scenarios how is the issues starts to show up if there is something triggering it, Also enable the debug for both integration and devices that disconnect, then post FULL logs it may give us an insight of what causing this issue!

So I deleted the device from local tuya and tuya app. Readded to tuya app, killed app and blocked tuya via DNS. Trying to add it again with localtuya gives "Connection to device succeeded but no datapoints could be found. Please try set-up again. If problem persists, create a new issue (including debug logs)."

blocked tuya via DNS

It's been many cases where people said that blocking devices DNS will make the devices goes into zombie state.
I didn't block my devices from internet so I can't give much information but

Upstream quote:

NOTE 2: If you plan to integrate these devices on a network that has internet and blocking their internet access, you must also block DNS requests (to the local DNS server, e.g. 192.168.1.1). If you only block outbound internet, then the device will sit in a zombie state; it will refuse / not respond to any connections with the localkey. Therefore, you must first connect the devices with an active internet connection, grab each device localkey, and implement the block

More:

Once everything was in order (devices working correctly), I added the tuya device to my blocklist to disable internet access to the spotlight and disabled cloud API in localtuya config

Block Your Device(from internet access) in your Router, just in case they have/want to live their own life, and don’t “snap up” a forsed-push-update(if such exist for specific Devices/Brands)
And if they have a HA-Auto-Update_entity associated with a Device, Disable it as-well

Unblocking DNS didn't help either

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

You're stale

Not solved yet

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

You're stale

not solved

To be honest, I have no idea what's causing this issue or if it has anything to do with LocalTuya. Currently, when this problem occurs, the device won’t connect until it is unplugged and then re-plugged. It no longer accepts any local connections—not just from LocalTuya, but from other local tools as well. While it remains connected to the internet and can be controlled through the cloud, it refuses to connect locally. Restarting the Home Assistant instance doesn’t help. Unfortunately, this issue hasn’t happened to me, possibly because I don’t have many devices, and the logs aren’t reporting anything unusual.

My device, after being unavailable for several hours, comes back online by itself. It's a cyclical behavior!

My device, after being unavailable for several hours, comes back online by itself. It's a cyclical behavior!

Enable the debug for both device and integration then wait for it's dc'd and come-back post the logs here it may be a lot of lines so you can put into txt file.

Just an update from my end. The two Feit dimmer switches (mentioned above) are working fine again after several HA updates. Not sure which one did the trick.
However, I have 3 LED drivers (from Ali Express) that were all purchased at the same time (same type). One of them dropped out a month ago and when I try to reconnect it I get the message "connection succeeded but no data points found". The other two are working fine. And all three work in the Tuya app. I checked all the settings that I could find in the Tuya cloud but there are no differences between the three. The "local key" is still correct.
I also had two curtain motors (same type). One of them dropped out a few weeks ago. Same problem when trying to reconnect, "connection succeeded but no data points found". But after updating to 2024.10.1 this morning, it's working fine again. Though I still can't reconnect the LED driver above.

Not losing and sleep over it. Just reverted back to the official tuya integration for that device and will check periodically whether I can reconnect through local tuya.

home-assistant.log.1.txt
@xZetsubou is this the log you need?
The device with the disconnecting behavior is "Mesa do Computador", its a led strip controller.
I was suspecting of poor wifi connection, but it does not keep disconnecting with oficial tuya app, and I replaced it with a magic home device and the magic home led strip controller does work correctly, so I think it's not a wifi issue.

After an internet outage the next LED driver died with "unavailable". I deleted the device and tried to resurrect via "configure". But again "connection succeeded but no data points found"
Seems like they're dying one by one.

I have the same problem... But it is very strange...
Tuya app from my phone, find the device in an offline state (of course, if I restart the device, it will be back online)
LocalTuya, gets the same info as Tuya app, even if I use it without cloud.

But, if you ping the device, all good, the device have network connection...

Edit1: If I restart the wifi router, it has nothing to do with, it will not solve anything, only the device restart will do it...

This sounds very similar to a problem I had with the original localTuya when trying to use any Tuya device that did not go through the Tuya hub and only connected to the network to update data. This was predominately battery powered devices.