How I made Tuya-Local work with full color controls

HOWTO: TuyaLocal and full color control under HomeAssistant

I spent a lot of time- weeks- trying to find instructions for how to do all of this. I never did find a coherent decription of how to do any of this, so I figured I’d help those who come after me. I have personally observed this process to work for DayBetter and Feit Electric smart bulbs. It probably works for other generic Tuya-based bulbs that can be controlled with the SmartHome app. Thanks to Tinkerer and NR in the HomeAssistant Discord for giving me enough foundational knowledge to make this HOWTO possible.

Before beginning: Install HACS first, then use HACS to install LocalTuya. Use the web page at GitHub - rospogrigio/localtuya: local handling for Tuya devices for instructions on how to do this. This same page includes instructions for how to set up an account at iot.tuya.com, which is required for getting access to the encryption key on each bulb. Don’t skip this step, and follow the instructions very precisely.

This HOWTO assumes you already have python and NMP installed.

If you haven’t already, install the tuya-cli utility by doing this at the command prompt:

  npm i @tuyapi/cli -g

Pairing the bulbs: Follow the instructions on the box that the bulbs came in (they may vary depending on the time of manufacture and the firmware installed.) Use a piece of tape and label each bulb so you can keep track of which one goes where. Make a note of the bulb friendly name and leave room for the IP address and encryption key. Write small if you have to.

It helps to keep order and sanity if you set up static IP addresses assignments for each of the bulbs in your router or DHCP server. If the bulbs change addresses, you can lose local control of each bulb, but cloud-based control will continue to work. This can be somewhat confusing and annoying.

Keep track of the names, tuya device IDs and IP addresses as you go. After the bulbs are checked in, you can use the tuya-cli utility to collect the encryption keys from each bulb.

After the bulbs are added, use the tuya-cli utility to get the encryption keys for each bulb/device. From the command line, execute this:

tuya-cli wizard

You will be asked for your API credentials on the first run, but those will get cached for subsequent runs. After that you will be asked for a single device ID for one of the tuya devices in your network. All it needs is one. The utility will produce JSON-formatted text containing the names, device IDs and encryption keys for each device attached to your tuya developer account. Make notes of these and don’t lose them.

Adding the bulbs to LocalTuya:
I added mine one at a time. There may be other ways, but the one at a time model gave me some stability in the process. Act as the spirit moves you. When adding the bulbs, there are many options in three separate steps.

The first step is where you pick a bulb from the list of known tuya devices, by its IP address and the name listed in the Tuya app.

The second step is where you give the bulb a frienldy name and put in the encryption key. Scroll down to the bottom of the data entry form and ensure that the bulb is listed as “20” with a checkmark beside it.

If this second step is successful, in the third step you will be asked what type of device this is. Answer that it is a “light.” If the IP address of the bulb has changed (look for static IP, above) You will be brought back to the second step.

The fourth (final) step is to add the particular data points for the bulb.
Set “Brightness” to “22”.
Set “Color Temperature” to “22”.
Set “Color Mode” to “21”
Set “Color” to “24”
All other setpoints can remain in their original state.

I have to admit that none of these settings make the slightest bit of sense to me. I found these settings to work through brute force twiddling the values over a very long period of time and learned that these particular gave me color wheel, temperature and brightness settings that I wanted to have access to. I will gladly revise and extend this howto if anyone discovers how a better way to do it.

26 Likes

Thanks just what i needed

And also Scene: 25

7 Likes

Hi, totally lost on getting color, dimming, brightness etc configured in localtuya. I just have the On/Off switch. Entered Bulbs, LED Strips and Switches and they all working, just no features listed above.

When I add a device (following your steps), I cannot find where to add the brightness, color etc(step 4). All I see is options for adding DPS and DPIDs. Protocol Version, Local Key etc.

Cannot edit entity either. Can you please explain how to add those, or if need be I can edit the configuration files or light.py. I don’t think I have customize,xxx file anywhere.My HA Core 2023.1.6 & LocalTuya Rel 5.0.0 .

I have read the documentation and still cannot get anywhere. Will appreciate any assistance. Thanks in advance.

Works wit Deltaco Decklights

Works with Lumary Smart Flood lights RGBW

In initial setup bulb is listed as “20” with a checkmark beside it

Set “Brightness” to “22”.
Set “Color Temperature” to “22”.
Set “Color Mode” to “21”
Set “Color” to “24”
Set Scene: 25

Thanks for this thread, super helpful!

Slight difference in DPIDs for “Bright” brand color bulbs and possibly others:

brightness: 22
color temp: 23
color mode: 21
color: 24
scene: 25

12 Likes

Sorry for necro, but this resolved my issue and fixed all functions for my smart bulb. The info OP provided got me half way there, but whites/temperature did not work.

For the sake of anyone Googling this issue, the model of the light is:

Arlec 9W 720lm RGB+CCT Grid Connect Smart LED Downlight
SKU: 0335074

2 Likes

Spent a week trying to figure this out. This fixed it for my LED light strip so I can now do color select. Thanks!

I’m not sure what I’m doing wrong, I can’t get my LED light working (RGB with WW/CW temps) into localtuya.

For this light, I’ve found all the data points on Tuya dev platform, but despite the product getting into into Home Assistant, it is “Unavailable” and I can’t even turn it on.

I’ve tried all of the data points people have shared in here, also the ones indicated on the dev portal. None of them will allow me to make the device become available in Home Assistant.

{
  "result": {
    "properties": [
      {
        "code": "switch_led",
        "custom_name": "",
        "dp_id": 20,
        "time": 1705434823728,
        "value": true
      },
      {
        "code": "work_mode",
        "custom_name": "",
        "dp_id": 21,
        "time": 1705434785014,
        "value": "scene"
      },
      {
        "code": "bright_value",
        "custom_name": "",
        "dp_id": 22,
        "time": 1705431400653,
        "value": 701
      },
      {
        "code": "temp_value",
        "custom_name": "",
        "dp_id": 23,
        "time": 1705431402915,
        "value": 758
      },
      {
        "code": "colour_data",
        "custom_name": "",
        "dp_id": 24,
        "time": 1705431364516,
        "value": "00b403e803e8"
      },
      {
        "code": "scene_data",
        "custom_name": "",
        "dp_id": 25,
        "time": 1705412782630,
        "value": "000e0d0000000000000000c80000"
      },
      {
        "code": "countdown",
        "custom_name": "",
        "dp_id": 26,
        "time": 1705412782630,
        "value": 0
      },
      {
        "code": "music_data",
        "custom_name": "",
        "dp_id": 27,
        "time": 1705412780833,
        "value": ""
      },
      {
        "code": "control_data",
        "custom_name": "",
        "dp_id": 28,
        "time": 1705412780833,
        "value": ""
      },
      {
        "code": "power_memory",
        "custom_name": "",
        "dp_id": 33,
        "time": 1705412782734,
        "value": "AAEAAAPoA+gD6AAA"
      },
      {
        "code": "mic_music_data",
        "custom_name": "",
        "dp_id": 42,
        "time": 1705412782630,
        "value": "010000016432000003e8007803e800f003e8003c03e800b403e8012c03e8"

Thank you for this!
Worked for 4 bulbs and a MiBoxer WL-Box1 2.4Ghz gateway.

:bowing_man: :+1:

@jellytotz I have the same DPs for my bulb (checked in Tuya Dev) and I am unable to get it to work either. Have you succeeded? If so, could you let me know the configuration? (The bulb I have is a Wipro Garnet Smart Bulb)

Just an idea guys, are you also using the tuya cloud integration?
I did have to remove it first to overcome some issues.
Also, try by closing the tuya app.

1 Like

No I haven’t got it working yet. It’s the only bulb that won’t work on local tuya.

@Nick4 I’ve done that, but this is the only bulb that local tuya won’t get working. All my plugs and other bulbs work fine.

Were you able to add the bulb to the integration at all?

Yes I can. But it local tuya states it’s Unavailable after being added. When setting it up, despite finding the data points in Tuya dev platform, they state as -1 if I recall correctly i.e. not showing the datapoints I know should be there. This is unlike my other devices, where I can see all the data points.

This is exactly what I get.

This is exactly what I was looking for, thank you!!

This worked for a Mirabella Genio Wi-Fi Dimmable 19W BC RGB+CCT UFO LED Bulb

When playing around with the different settings I had to restart the localtuya integration and turn the light on and off at the wall sometimes to get it to update properly.

Closed the tuya app, and the bulb become availible within fractions of a second in HA

1 Like