Tuya state reporting slow or non existent

Here is an automation posted on another thread by sesardelaisla which will reload the entities every so often, obviously not a fix but it might help some people.

alias: Reload Tuya
description: ''
trigger:
  - platform: time_pattern
    hours: /1
condition: []
action:
  - service: homeassistant.reload_config_entry
    target:
      entity_id:
        - switch.tuya_01
        - switch.tuya_02
        - switch.tuya_03
    data: {}
mode: single
1 Like

Iā€™ve been having the same problem. After a length of time Tuya and HA donā€™t communicate any longer. I was tired to restarting HA to fix this mess, so I switch to Local Tuya tonight. Problem solved.

1 Like

I also facing the same issue. Tuya devices not updated after updating to v2021.12.xx. I have to restart HA , then it will update the status. seems like the it does not receiving notification from the tuya server.

1 Like

I have to admit I am really dissapointed with this whole TUYA situation lately. The image I have is that they came with much bravado and showmanship to this whole ordeal. They had huge plans for make to ultimate integration with local support etc. I donā€™t doubt it is still coming at some point, but it seems that couldnā€™t deliver or are not really interested. Frenck did a lot of work to fix the integration all by himself (thank you Frenck like always), I am not mistaken, and somehow feel that Tuya itself is just lacking in participation. It is not just on HA side they give a bad image, but it makes question should I buy their products anymore.

And I might be wrong many ways, but this just how I feel.

2 Likes

I completely agree with you. The issues only started with the official Tuya integration so the buck stops right at Tuyaā€™s door. I had my concerns when I had to endure a painful sign up process to the Tuya cloud application but persevered. I have not been rewardedā€¦ I definitely wonā€™t be buying any more Tuya related products as thereā€™s far more to life than beta (alpha?) testing for a company that has badly dropped the ball.

there seems to be a pending fix for this issue on github already Use the documented API method to refresh auth token by bpfoster Ā· Pull Request #51 Ā· tuya/tuya-iot-python-sdk Ā· GitHub

heres my solution as well: Tuya actions get's stuck - #4 by andreasc

i find it more reliable to reload config entries than reload entities. entities also were getting stuck. now it have been resolved.

I havenā€™t had to reload the Tuya integration for almost 24 hours. Anyone know if there was progress on the implementing the fix? Or, have I just been lucky? :grin:

Update: :slightly_frowning_face: Had to reload again at just about the 24-hour mark.

the PR fixing the issue has been merged today, so itā€™s likely to be included in the 12.6 release. in the meantime the manual fix is easy.

Unfortunately, the manual fix of restarting or reloading the integration also screws with the logs and makes the items unavailable for a moment, and resets the last state to the current time.

As I have automation that uses a time delta since the last state, this resets the delta.

One of those automations is a heater in the garage fridge to avoid my fridge malfunctioning due to the cold, as it sits right now if I use the reload integration it rests the time since last switched and may cause the heater to run longer than needed, thereby warming the refrigerator up to the point that it can spoil food.

So while the fix may be easy, it is not useful for all.

I hope the PR merge fixes the issue.

I think @molnart might have been referring to the PR as the manual fix. It can be applied in just a few minutes. Two small changes need to be made in the /usr/local/lib/python3.9/site-packages/tuya_iot/openapi.py file. The changes can be seen here:

It took me longer to figure out how to access the file than to make the changes. In case it helps anyone, I use portainer which makes it easy to launch a shell in the homeassistant container. Since I didnā€™t want to mess with installing an editor in the container shell, I copied the file to my homeassistant directory, edited it with WinSCP, then copied it back to the proper location. After a server restart, the Tuya integration seems to be stable, although time will tell if that fix worked. Hope this helps.

Where did you find the file? Iā€™ve spent some time trawling through my HA server but havenā€™t been able to locate it anywhere let alone in directory tree shown.

TIA

anyone any idea how to get to the openapi.py file on HAOS (the default for Pi) install?

Latest HA update seems to have fixed this issue. Iā€™ve just installed it hence my cautiousness but itā€™s looking good with button states correctly reflected on the dashboard.

HA 2021.12.6 solved it for me. See release notes (Update tuya-iot-py-sdk to 0.6.6): 2021.12: New configuration menu, the button entity, and gorgeous area cards! - Home Assistant

Running 2021.12.10. Occasionally I had this issue that status of tuya bulb in HA doesnā€™t sync to the actual status of the bulb. Not sure how to solve it.

Same as @henry8866 here.
Status of TUYA bulbs get out of sync with HA but it gets fixed after a TUYA/HA reload/reset.
Really thinking about moving to LocalTuya at this point :pensive:

I was moving from localtuya. Itā€™s no better. When I was using localtuya, devices were randomly became unavailable, had to remove it and add it back to fix it.

Just reloading that particular device through:

Settings ā†’ Integrations ā†’ LocalTuya integration ā†’ Device ā†’ Hamburger Menu ā†’ Reload

should be enough. No need to remove and adding it back.

I experienced similar with Local Tuya at the beginning but this phenomenon stopped after a while. Just give it enough time to settle in.

1 Like

Thanks for the information. I may try it later if localTuya is stable.
Do you know if there is service that I can use in NodeRed to do the ā€œreloadā€ as you described?