Tuya -9999999 sign invalid – reloading was not enough in my case, local TinyTuya/MQTT workaround

This is not a universal fix for Tuya error -9999999. I am sharing a workaround that is currently working reliably in my installation and may give others another direction to investigate.

I was experiencing the recurring Tuya error:

network error: (-9999999) sign invalid

In my case the official Home Assistant Tuya integration could appear healthy and the devices remained visible, but commands sent to Tuya devices failed.

Reloading the Tuya integration alone was not enough.

An important observation in my installation was that after this happened, I also had to authenticate/login to Tuya again. After re-authentication the official integration could work again, but I did not consider this reliable enough for devices where control is important.

I have seen suggestions to automate reloading the Tuya integration when this error occurs. That may help in some installations, but in my case a reload alone did not solve the complete problem because re-authentication was also required.

My setup

My Home Assistant runs on a server at home. The Tuya devices I wanted to control are at another location.

The relevant devices are connected through a Tuya gateway and include two irrigation controllers and a power socket.

Instead of depending on the Tuya Cloud command path for these devices, I now use:

Home Assistant → MQTT → remote Linux host → TinyTuya → Tuya gateway → child devices

Home Assistant publishes commands through MQTT. A small Python service running locally at the remote site receives them and communicates with the Tuya devices locally using TinyTuya.

The service also reads the actual device state and publishes it back to Home Assistant through MQTT. Therefore Home Assistant does not simply assume that a command succeeded — the state can be confirmed from the device.

This approach has been working in my installation and, importantly, control of these devices no longer depends on the official Tuya integration remaining authenticated.

Important

I am not suggesting that this fixes error -9999999 itself, and I am not claiming that the same architecture will work with every Tuya device, gateway, protocol version or firmware.

The useful direction may simply be this:

If a Tuya device supports reliable local communication, consider separating critical device control from the Tuya Cloud integration instead of repeatedly trying to recover the cloud session.

In my case this meant TinyTuya locally, MQTT between locations, and Home Assistant as the user interface/control layer.

I documented my particular configuration, observations and implementation here:

https://github.com/oliwerpol68-jpg/dzialka-guard/blob/main/docs/home-assistant/tuya-9999999-case-study.md

I am posting this mainly as a case study and another troubleshooting direction. If somebody experiencing the same -9999999 sign invalid problem tests a similar approach, I would be interested to know whether it also works with other Tuya gateways/devices.