LocalTuya light sensors

I am making another attempt at getting my tuya devices integrated via LocalTuya.

I am not sure how to integrate a couple of attributes that are defined as multiple value in json code. The specific example is below:

      {
        "code": "colour_data_v2",
        "dp_id": 24,
        "type": "Json",
        "values": "{\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}"
      },
      {
        "code": "scene_data_v2",
        "dp_id": 25,
        "type": "Json",
        "values": "{\"scene_num\":{\"min\":1,\"scale\":0,\"max\":8,\"step\":1},\"scene_units\": {\"unit_change_mode\":{\"range\":[\"static\",\"jump\",\"gradient\"]},\"unit_switch_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"unit_gradient_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"bright\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"temperature\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}}"
      },

I have simply added these as sensor entities. However, that results in an unformatted string for a colour data entity and a scene data entity:

How do I define this when adding or editing in LocalTuya so that I can access the specific details?

Are you adding the light as a light or a switch? It should be a light.

It should pop up a window to “Configure entity”

You need to fill in the DP_IDs there after the first one, which is usually (DP_ID 20) on the previous page. They are almost intuitive, but not quite so you may have to guess or search the forums.

"dps_strings": [
        "20 (value: True)",
        "21 (value: scene)",
        "22 (value: 10)",
        "23 (value: 0)",
        "24 (value: 00b403e8000a)",
        "25 (value: 0730300200000000000a000003e8303002007803e803e80000000030300200f003e803e800000000303002003d03e803e80000000030300200ae03e803e800000000303002011303e803e800000000)",
        "26 (value: 0)"

Only the switch will show up once it is setup, the controls and colors are hidden in a popup.

I used the LocalTuya “Add new device” and added the first DP_ID (20) as light, using the initial “Configure entity” window, then added the entities using the following entity windows as follows:

21 - select
22 - number
23 - number
24 - sensor
25 - sensor
26 - number

When you set up the light platform you should be able to fill out the required fields on that initial page.

the id will dp 20

brightness should be dp 22
color temp dp 21
color mode dp 23
color dp24
scene dp 25

The below is incorrect, they should be entered on the light platform, not as individual sensors/numbers

1 Like

Hi, before your reply above, I finally cottoned on to that and added most of the DP_ID values on the initial screen. Looks a lot better. I have been trying to add LocalTuya for some time now but had been one of those users for whom the integration did not allow me to add or amend any more than one device. Recent system updates must have plugged this hole and it is the first time I have added and edited devices successfully. Finally can automate my tuya devices. cheers

1 Like

I’m attempting this with some new bulbs, but the devices show as unavailable.

"data": {
    "device_config": {
      "friendly_name": "A21 Bulb",
      "local_key": "xxxxxxxxxx",
      "host": "10.150.66.174",
      "device_id": "xxxxxxxxxxx",
      "protocol_version": "3.3",
      "model": "A21 Bulb",
      "dps_strings": [
        "20 (value: True)",
        "21 (value: white)",
        "22 (value: 1000)",
        "23 (value: 0)",
        "24 (value: 014a024c0028)",
        "25 (value: 000e0d0000000000000000c80000)",
        "26 (value: 0)"
      ],
      "entities": [
        {
          "id": 20,
          "friendly_name": "bulb test",
          "brightness_lower": 29,
          "brightness_upper": 1000,
          "color_temp_min_kelvin": 2700,
          "color_temp_max_kelvin": 6500,
          "color_temp_reverse": false,
          "music_mode": false,
          "brightness": 22,
          "color_temp": 21,
          "color_mode": 23,
          "color": 24,
          "scene": 25,
          "platform": "light"

EDIT UPDATE: If I just set ID, the light works fine - on/off no issues. Working through IDs one by one

Hi, I don’t believe this is quite right. I’m pretty sure that 21 is the Colour Mode (White, Colour, Scene, Music) and 23 is Colour Temperature. Well, that seems to work for my Arlec/Tuya devices.

I think Andrew is correct here. I was struggling to understand the whole dp concept, but now I found this reference on Tuya developer site Function Definition of Spotlight-Tuya IoT Development Platform-Tuya Developer