Homeassistant и Tuyalocal

I’ve been slowly building a “smart home” for a while now. After a lot of experimentation, I settled on the combination of Zigbee and Home Assistant.

Currently, my device map looks something like this: Device map

Unfortunately, I still have several Tuya devices that use Wi-Fi. They operate through Tuya’s cloud, which has a closed and rather clunky protocol. The simplest way to integrate them with Home Assistant is via a cloud-based integration. However, the downside is that, without internet, the lightbulb won’t be controllable. Additionally, there are significant delays when controlling it. I had been putting off the task of gaining control over these devices to disconnect them from the cloud.

One option is to use the LocalTuya integration. However, for some reason, with my lightbulb, it only supported turning on and off. Color temperature and color adjustment weren’t available, and when turning it on, the brightness would be set to a random level.

After some research, I found this issue. To summarize, typically, Tuya bulbs use several Data Points (DPs) to control color, temperature, and brightness. However, my lightbulb uses a single DP that includes all device parameters at once.

Taking matters into my own hands, I created a patch. Unfortunately, it’s rather makeshift, but it works.