Problems setting up TUYA integration

I’ve been playing with Home Assistant for a short while and I’m very impressed at the easy installation and how most of my devices are picked up.

I’m running Home Assistant 2021.12.8 on RPi3B (haos_ova-7.1).

I do have a problem, however, to get my TUYA devices connected.

I’ve set up the required account at iot.tyua.com, created a cloud project, arranged for the autorizations and linked my account. On the Tuya project overview page I can see my devices (two power switches).

tuya-cli wizard also lists these devices, so I’m sure the API key and secret and device ids are correct.

In HA I setup Tuya integration and enter the requested API key/secret and login data. This completes succesfully (admittingly after several failed attempts with wrong API and/or login data :grinning:).

scrot20220111082620

So Tuya seems to be set up, but no devices are shown.

FWIW, I do have some tuya_iot errors in the log even though I understood this was solved in 2021.12.6.

2022-01-10 22:18:49 ERROR (Thread-7) [tuya_iot] error while get mqtt config

I ran out of ideas. Suggestions are welcome.

And then, all of a sudden, the devices appear. More than 12 hours after setting up Tuya integration.

Is this normal?

EDIT: The devices are there, but do not work. When I click on a handle to enable a switch, the handle goes to the right and becomes blue (ON). After a second or so it shifts back to the left and becomes OFF again.

So it seems that the device, a “smart power plug”, is working, but the state is not correctly understood.

When I switch the device on, the handle goes to the right and becomes blue (ON). After a second or so it shifts back to the left and becomes OFF again. The power plug did switch on (and remains on).

Since according to HA the device is OFF, I cannot switch it off anymore.

What I can do, is switch it on and immedeately (while it is still ‘blue’) switch it off. Then the power plug also switches off.

Is there anything I can do to further troubleshoot this? Or a way to force a switch-off, even when HA thinks the device is already off?

I moved my devices from built-in Tuya integration to Local Tuya integration. Now everything works.