Hi all, I’ve upgraded to the 10.x core and upgraded Tuya to the IoT Platform, exactly as described in the instructions. This all worked OK and my 13 devices were successfully added to HA. However the integration doesn’t work properly. A device (smart life switch) can be switched ‘on’ from the dashboard, but the ‘switch’ reverts back to the ‘off’ state even though the device remains on. The device can still be controlled correctly from the Smart Life app.
It seems there is a problem with the MQTT configuration when Tuya is installed, this is the Core Log:
[tuya-openmq] error while get mqtt config
ERROR (Thread-4) [tuya iot] error while get mqtt config
ERROR (Thread-4) [root] Uncaught thread exception
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py", line 174, in run
time.sleep(self.mq_config.expire_time - 60)
AttributeError: 'NoneType' object has no attribute 'expire_time'
Does anyone have any suggestions what the problem might be and is there anything that I can do to fix it, or to work around it?
Frenck resolved this - thanks! - Device Status Notifications service had not been enabled in Step 6 of the Tuya Integration instructions. Enabling this allows MQTT to work properly within the Tuya Intgegration.
I had that same issue and solved with the same solution. It was selected during setup however.
Unfortunately The integration does not show any devices. (Only one connected in the app)
And in the Tuya IoT dashboard it visible (the outdoor lamp).
Logger: tuya_iot
Source: /usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py:161
First occurred: 3:59:45 AM (2 occurrences)
Last logged: 5:58:46 AM
error while get mqtt config
However I have step 6 enabled and have made sure few times.
If I restart Home asisstant it will work for few hours then the switches will stop working with the above error in log file.
You may find that disconnections from the Tuya cloud appear at suspiciously regular intervals in your logs, so it appears to be a ‘feature’ on Tuya’s side (and entirely down to that - the coincidence with the recent HA December upgrade is nothing more than a coincidence).
If you look at some of the GitHub discussions, you’ll see that some users are using an automation to periodically reload the integration and keep the connection up consistently. This approach is working for me at least.
I can confirm same behavior.
Only Reloading integration did not help. Only HA restart did. but i few hours it happens again.
Logger: tuya_iot
Source: /usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py:161
Glad in a way to know I’m not the only one facing this. Thought tuya team had resolved the issue due to resourcing. I’ve tried to de-authorised and re authorise device notification and restart HA. Still encountering the same issue.
Logger: tuya_iot
Source: /usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py:161
First occurred: 13:28:52 (1 occurrences)
Last logged: 13:28:52
error while get mqtt config
Is there a way to have an automation to monitor the log for this particular error and auto trigger an integration reload as a workaround?
Update:
Wonderful work by ResteNarquois
He has done up the script here.