Tuya v2 does not refresh states of entities

Hey,
I also tried to move to Local Tuya.
I installed the Integration via HACS and I got all my Local Keys ans stuff from the Tuya IOT website.
Just as described.

When I try to set up my Plugs and Lightbulbs with the Local Tuya integration in Home Assistant I don’t get the dropdown menu. It is empty.
And when I try to configure them manually in the configuration.yaml I only get an error.

Do I have to delete the Tuya v2 integration to get this work? Does Home Assistant not allow these two to coexist?
At the moment I did not try, because if it’s another problem I had to do all the configuration again :smiley:

Thanks

The 2 integration can coexist, I deleted the Tuya official once everything was working fine.

I do not understand what you mean when you say the drop-down menu is empty.

For me the only problem was to find the local key, but when I found out how to get it all was quite easy, no need to configure manually the configuration.yaml, I could manage all via visual interface

After installing the repository with HACS I went to the Integration section. With the “+”-Button I chose the Local Tuya integration. This opens a pop-up window where I had to configure my device.
But there is nothing listed.
If I try to fill in the configuration manually nothing happens.

this is what I get, all devices are listed

this is what it should look like, but i only get text. the are no discovered devices.
instead I get an option to fill in the from manually with name, host, lokal key and device id.
i know all of these but when i fill them in nothing happens.Unbenannt

After few minutes of waiting I get an error.

The logfile shows this:

this is completely irrelevant to the issues described in here. open an issue with localtuya

1 Like

I’m having the same issue, I’m not using LocalTuya. I’m on the latest version of HA (2022.2) which includes the fix for refreshing the Tuya API key but I’m still not getting the status of the Tuya devices reported to HA.

The devices themselves work fine, I can switch stuff on & off but the status just won’t update which means I can’t use their state in any automations or templates.

The status works fine in the Smart Life app though.

1 Like

The only thing in my log related to Tuya is this:

Logger: tuya_iot
Source: /usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py:117
First occurred: 16 February 2022, 22:44:15 (2 occurrences)
Last logged: 16 February 2022, 22:44:15

Unexpected disconnection.16

However that also coincides with an internet outage we had so it’s probably unrelated, it only appears twice and the status problem was occuring before then.

I’m afraid this is an ongoing issue that is affecting many Tuya users, and there are several open issues on Github about it.

It might be worth keeping an eye on this one, as the developer is asking for help to solve a problem which is acknowledged to be entirely on Tuya’s side - it seems that device updates are just not being reliably returned to HA through the v2 API. As you are finding, it doesn’t stop us controlling the device, but it does prevent us running any meaningful automations or templates based on device states.

A dirty fix is to simply reload the integration (Configuration → Devices & Services → click on the 3 dots on the Tuya integration, choose ‘Reload’). Some users have set up an automation to do this at timed intervals - say 15 minutes or so - but the problem with this is that the reload might occur up to 15 minutes after you’ve used a given device.

If errors were showing in the logs, it would be possible to use this as a trigger for the automation reload, but even if you set log level to Debug, the integration is pretty uninformative about what it’s doing, which of course makes trouble-shooting even harder. I suspect the error you saw was indeed just down to your internet outage.

1 Like

Thanks @reste_narquois I’ll sub to that Github bug and keep a watch on it.

Well, it is June now and I have recently come to have this problem. I have rebuilt all the Tuya.com end, authorisations etc. I do not believe that it is my configuration as the now infamous “reload” fix works a treat. All the same I would like a proper integration, I have to reload every minute, because I use a Tuya smart meter to measure solar panel production and take decisions on how to use the power accordingly.

Configuration is

  • Home Assistant Core 2022.6.6
  • Home Assistant Supervisor 2022.05.3
  • Home Assistant OS 8.2

Does anybody understand where the problem lies:- clearly there are two parties to any conversation, but where in the chain does that conversation breakdown?

Had the same problem but this solved it for me…

Thank you. I’m going to try that when I’m back home

I have tried it, but it makes no difference

1 Like

I have the same problem - sensor updates are completely unreliable.

Bad scenario : HA turns on your (expensive) electric fan heater because its too cold, then doesnt turn off because the temperature state in HA doesnt get updated. Result = big energy bill.

I have manged to move most of my devices to localtuya, but when configuring localtuya and trying to add the devices, only some of them showed up at first - a day later a few more appeared and so on until i got them all except for motion and brightness sensors.

Out of 5 motion and 3 temperature sensors, only 1 could be added to localtuya. The rest seems to have gone awol and cannot be added manually either.

All sensors works fine in the smartlife app, but in HA readings are most of the time (but not always) outdated.

I also considered the auto-reload hack but it doesnt always work for me - and in any case it really should not be necessary.

I have now ordered a zigbee dongle and some zigbee sensors and will see if they work ok - hopefully they will, and i will then ditch the tuya ones.

As a temporary workaround, I have now created some scenes in the Smartlife app which can turn heating, lights etc on and off. They are not very sophisticated but at least for now they work and are reliable.

To get the full HA functionality you could for example have smartlife turn on a light on motion detection and then in HA you could pretend that light on = the same as motion detection and then add your logic as usual. Pretty clumsy but would work.

I dont know where to report this to Tuya (but looking at all the posts above, it seems nobody cares)

Would replacing everything with zigbee be a good idea? I have about 35 tuya devices so would be a bit of an investment, so maybe I can get away with just replacing sensors and leaving plugs and lightbulbs as they are.

If anybody have some great ideas - please post.

1 Like

Did you give the tuyalocal addon (not the localtuya addon) a try?
I seems you can add devices that are not supported by the addon yet.
I want to give that one a try, but I have to dive in to how to add an unsupported device first.

Reloading the Tuya integration every 15 minutes probably works, but it’s a neater solution to reset before any automation triggers a switch, or for sensors (eg. temperature) check to see if the value has changed after 30 minutes, and if not reload the config_entry.

I couldn’t get the Unavailable or Unknown status to work reliably as triggers, so setting up a variable to check for no change after a set period is a reasonable workaround

Mine is still not updating. It did resume working a few days back, but stopped again. I’ve written an automation which checks if it’s been more than 30mins since a Tuya sensor updated, and if so reloads the integration (also counts the number of reloads via a counter I created in ‘helper’).

The Tuya sensor needs to be one that isn’t ‘low power’ so fires off near constant updates. Normally that means USB powered and not battery. The reload command can point at any Tuya device.


alias: Restart Tuya if failed for 30min
description: ""
trigger:
  - platform: time_pattern
    minutes: /5
condition:
  - condition: template
    value_template: >-
      {{ now() -
      states.sensor.air_sensor_study_particulate_matter_2_5_um.last_changed >=
      timedelta (minutes=30) }}
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: sensor.hot_water_tank_1_temperature
  - service: counter.increment
    data: {}
    target:
      entity_id: counter.tuya_failed
mode: single

Mine is mains powered (ceilingfan) so that should not be the problem.

Mine had been working quite well, until tonight I noticed the states (on and off) for my Tuya controlled power bar on my Home Assistant Dashboard did not match the actual states of the power bar itself.

I tried to reload the service in HA, but it didn’t change anything.

I then went into my firewall, and for a test, I enabled a rule that I have to block traffic from various countries (Russia, China, etc.).

Once I did this, I reloaded the Tuya service in HA and the states on my HA dashboard updated correctly.

I then reverted to blocking the traffic of the unwanted countries, add oddly enough changes to my dashboard continue to remain in sync with my power bar.