Tuya lights/switches delay in updating states, is it only me?

EDIT: The below seems not to have been a good idea. After a while, the tuya integration stopped loading at all. I think this might cause too many API calls on the tuya side :wink: So I guess, we will have to wait.

Since for me manually reloading the integration at least updates the states, I created an automation that just reloads the integration every 2 minutes. Obviously by no means is this a “solution” and it obviously is incredibly inelegant. But at least I get a somewhat consistent (albeit with a max. of 2 min. delay) status updates. So for me this works as a stop-gap solution until the situation is resolved properly. Notice that when you reload the tuya integration all your devices become briefly unavailable (1s or so). In practice this is not an issue, unless of course you have automations that do something when a device becomes unavailable.

Anyway, if you want to use this stop-gap solution, below is the code of the automation.

description: ''
trigger:
  - platform: time_pattern
    minutes: /2
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: XXXXXXXXXXXXXXXXXXXXXXXXXX
mode: single>

In order to find out the entry ID, you have to check in the file /config/.storage/core.config_entries. Sicne this is a hidden .storage folder, I don’t think you can check that file with the file editor Visual Studio (correct me if I am wrong). Instead:

1. install the ssh add-on
2. open the ssh webUI
3. type the following command: less /root/config/.storage/core.config_entries

Look for the section with domain tuya:

            {
                "entry_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "version": 1,
                "domain": "tuya",
                "title": "XXXX",
                "data": {
                    "endpoint": "https://openapi.tuyaeu.com",
                    "auth_type": 0,
                    "access_id": "XXXX",
                    "access_secret": "XXXX",
                    "username": "XXX",
                    "password": "XXXX",
                    "country_code": "32",
                   "tuya_app_type": "smartlife"
                },

Let’s hope it get’s fixed quickly. There are already a bunch of github issues opened, so I think the devs should be aware.

Same issue here…

I’ve been having the same issue. The only way I have fixed it was to make sure that the Tuya app account is in the same country as the developer account you have it linked to. Unfortunately for me my Tuya app account as set to Ukraine so I had to create a new account and re-pair 29 devices to it (took all day) also in the cloud developer make sure you have the “notification update” enabled (I hope a called it the right thing) ugh hours of labor today…but it paid off :+1:

This script is still a great idea. Instead of automation, thanks to the great work from you I’ve just put them into a script and assign it to a button on my dashboard. 1 click beats 3 clicks any time :grin::+1: as and when required.

Same problem.
Just upgraded to core-2021.11.5, moved my Tuya devices from the old Tuya to the new “official” Tuya.
Home Assistant sends commands and the device responds, the Home Assistant changes to the new state, then goes back to the previous state.
In others words, turn a Tuya switch on, the HA icon changes from off to on, then less than a second later, changes to off. The physical Tuya switch remains on though.

What is broken?

[Edit 1]
Open issue in home-assistant/core:
Tuya switch not keeping its state when toggled - delay in switch state updating after last HA core update 2021.11.4 #60034

[Edit 2]
I thought I had authorized “Device Status Notification” but it was not. Authorized, restarted HA, and now Tuya appears to be working correctly again.
Follow this instructions carefully and be sure you have authorized the “Device Status Notification” API for your service:

Wondering if the Tuya integration would be able to provide an error message in the log if the “Device Status Notification” has not been authorized.

Same problem, big delay with update of status of Zigbee lamps and Zigbee switch.
Also slow reaction on switching on /off
Even after switching off or on, you have to wait quite long before you can switch it off/on again.
Looks that the new Tuya API from Tuya is giving problems / very slow performance.
core-2021.11.5
Home Assistant OS 6.6
supervisor-2021.10.8
Currently 21/11/2021 only my test Home Assistant is using the latest version core-2021.11.5
But this problem was also with previous version core-2021.11.4
And according me also with previous version like 11.3 etc (but it looked that problem became bigger and bigger).

My operational environment is now back again to the version of 8/10/2021
core-2021.9.7
Home Assistant OS 6.6
supervisor-2021.10.8
Here the old Tuya integration works fast en reliable.

I installed the old tuya integration through HACS. The current state of the new tuya integration is unusable.

Came here to post this. I put off going to latest home assistant as I knew it would be painful going to the new integrated Tuya.

Turned out not so bad, but the device status updates are awful. I mainly have switches and light bulbs, and all are the same. A long lag, or not updating at all. It was a pain in the ass fix all my scenes.

Luckily, I had Local Tuya installed via HACs from a while back, but unused, so I spent a few hours adding all my devices there as well. For now I’ve doubled up on my switches and bulbs in lovelace with a “local” suffix on each entity.

Anyone know what’s causing the delay?

Maybe this will force the developers hands on implementing and supporting local Tuya officially.

Same for me… response time can take up to 2~5 min.
But Tuya local integration shows the state changes instantly.

1 Like

I thought I had authorized “Device Status Notification” but it was not. Authorized, restarted HA, and now Tuya appears to be working correctly again.
Follow this instructions carefully and be sure you have authorized the “Device Status Notification” API for your service:

Wondering if the Tuya integration would be able to provide an error message in the log if the “Device Status Notification” has not been authorized.

2 Likes

I checked it again and i have authorized the “device status notification”. Also the region and tuya server is right. Still not working and it feels as if it is getting worse. I have two power sockets that show no changes at all until i restart the tuya integration. At the moment it is very frustrating! It was working so well and fast but now it is really unusable.

I had a look at my Tuya settings, and updated my projects data center to western Europe ( I did have it set to central ). Then I unauthorised and re-authorised Device Status, then restarted core on HA.

There’s still a nasty lag of anywhere between 5 - 20 seconds to receive the status in lovelace.

I will monitor to see if it’s improved any ( e.g. not updating the status at all )

After playing around, I would say, for me it’s moderately better ( I think western Europe was the correct setting for me but I did have central Europe selected in my project) but still rubbish for anyone relying on device status updates.

As a temp workaround until they fix this, if it’s not a hassle, give the HACs Local Tuya a try. It works perfectly for me for the basic light and switch functions that I need.

Didn’t take me that long to add my devices and the device keys can be pulled from the Tuya IoT developer portal using the API tool Device details request.

I can’t believe there still hasn’t been any communication from any of the devs or tuya on this.

fyi…your original issue was not getting any device status updates because you didn’t authorize that API service…everyone elses issue is the device status updates are slow, or not coming through intermittingly / timing out.

fyi - The HA devs are aware. Frenck has posted on this reported git bug in the comments :

If you like the issue, as suggested by Frenck, it will likely increase the priority of the issue and demonstrate a lot of people are hitting it. No point posting a comment if your symptoms are the same…just like it.

fyi…I don’t think its a straight up simple code fix on the backend or frontend of HA. Its more likely a combination of Tuya API responses suddenly taking longer than normal and not coming back at all in some cases.

Look here, if I set Tuya base to debug , and toggle a switch / lamp :

2021-11-23 11:24:27 DEBUG (SyncWorker_2) [homeassistant.components.tuya.base] Sending commands for device 27845426dc4f22a75a16: [{'code': <DPCode.SWITCH_1: 'switch_1'>, 'value': False}]

A full 8 seconds later in the log :

2021-11-23 11:24:35 DEBUG (Thread-6) [homeassistant.components.tuya] Received update for device 27845426dc4f22a75a16: {'switch_1': False, 'countdown_1': 0}

Sometimes, no response is received at all.

A tcpdump will indicate where the delay is being induced. I’ll be going there next.

1 Like

I spent the afternoon yesterday changing all my lights and switches to tuya local. Think I’ll just stick with this now.

1 Like

Yes, I’ve also just switch over to local tuya as well. It took me a substantial amount of time with 60+ lights, switches and cover but all is good now. The response is unbelievable fast.

New Tuya integration is not working as it should for now. State changes are extremely slow on HA side and due to that automations are not working as they should. I have also installed Local Tuya a month ago and still using it. It works the way it should. I would recommend people to try that until there is a fix on Tuya side.

Hi guys, we are working hard on fixing the slow response issue and will inform everyone once it’s fixed. Sorry for the inconvenience!

8 Likes