LocalTuya - Using Tuya IoT Platform to obtain not only Local Keys, but also DP (data point) IDs

Soo…finally to get LocalKey of tuya device, go to Tuya IoT Platform …Cloud…API Explorer…General Device Capabilities…General Device management…Get Device Information and insert device_id in the field and hit Submit Request.
In the right pane scrool until see "local_key":"your_local_key_for_your_device".
Simple, right?

1 Like

Edit1

As soon j complained i got it working…great video

was hoping it is that simpel as well, but i was not able to get that done…i am already failing at the tuya web page…got an account but no devices in there and cant find anything that could give me a key or so…

I tried using the Get Device Specification Attribute for my Lydsto vacuum, and it returns some data, but the DP IDs don’t match up at all with what local tuya shows me.

Get Device Specification Attribute:

{
  "result": {
    "category": "sd",
    "functions": [
      {
        "code": "power",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "power_go",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "mode",
        "dp_id": 3,
        "type": "Enum",
        "values": "{\"range\":[\"standby\",\"smart\",\"chargego\"]}"
      },
      {
        "code": "seek",
        "dp_id": 13,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "reset_map",
        "dp_id": 129,
        "type": "Boolean",
        "values": "{}"
      },
     ...
}

Local Tuya

1 Like

Hi there. Was Hoping you could lend me some assistance.
I’m totally lost and Very Frustrated here on this whole Device Control Page or I guess DP?
I’ve spent hours trying to figure out why my LocalTuya Devices are not correct.
I’m 71 but still pretty savvy in technology… But this Integration seems overly complicated. LoL
Example: All my Tuya Color Bulbs show up as a Switch. They turn On/Off but no other features like Color, or Dimming etc… Also Tuya Smart Plugs with Energy Monitoring don’t show up.
I think it has to do with Dozens of settings that have no explanation.
I’m savvy using the GUI Integrations and do have some limited experience in yaml as I’ve integrated my DSC / Envisalink security system, and have written several Automation’s, But again this Integration is way overly complicated.
Anyway Sorry for the long Rant here, but maybe you can help.
BTW: Everything works perfectly in the Smart Life App and on Alexa.
Hope you can help. Thanks in advance…

Hello…
I just watched your great YouTube Tutorial. I’m finding this LocalTuya Integration to be Way Overly complicated. I now have 17 Tuya devices Installed and as of 12/01/2022 I’m running the latest up to date HS. However LocalTuya does not address the specifics of my Devices.
Example: Color Light only has On/Off and as I now understand this DP-ID’s is the Problem ??
I would gretly apperciate any help you can provide as I’ve spent many hours experimenting on my own. I did manage to look up and find what I think is the DP-ID’s
I’ve Pasted the data below. Can you please advise if this is correct, and what data I need to fix the one light I am working on to learn. Called Bed 3
Thank you very much…

{
“result”: {
“category”: “dj”,
“functions”: [
{
“code”: “switch_led”,
“dp_id”: 20,
“type”: “Boolean”,
“values”: “{}”
},
{
“code”: “work_mode”,
“dp_id”: 21,
“type”: “Enum”,
“values”: “{“range”:[“white”,“colour”,“scene”,“music”]}”
},
{
“code”: “bright_value_v2”,
“dp_id”: 22,
“type”: “Integer”,
“values”: “{“min”:10,“max”:1000,“scale”:0,“step”:1}”
},
{
“code”: “temp_value_v2”,
“dp_id”: 23,
“type”: “Integer”,
“values”: “{“min”:0,“max”:1000,“scale”:0,“step”:1}”
},
{
“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}}}"
},
{
“code”: “countdown_1”,
“dp_id”: 26,
“type”: “Integer”,
“values”: “{“unit”:“s”,“min”:0,“max”:86400,“scale”:0,“step”:1}”
},
{
“code”: “music_data”,
“dp_id”: 27,
“type”: “Json”,
“values”: “{“change_mode”:{“range”:[“direct”,“gradient”]}, “bright”:{“min”:0,“scale”:0,“unit”:”",“max”:1000,“step”:1}, “temperature”:{“min”:0,“scale”:0,“unit”:"",“max”:1000,“step”:1}, “h”:{“min”:0,“scale”:0,“unit”:"",“max”:360,“step”:1},“s”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1},“v”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1}}"
},
{
“code”: “control_data”,
“dp_id”: 28,
“type”: “Json”,
“values”: “{“change_mode”:{“range”:[“direct”,“gradient”]}, “bright”:{“min”:0,“scale”:0,“unit”:”",“max”:1000,“step”:1}, “temperature”:{“min”:0,“scale”:0,“unit”:"",“max”:1000,“step”:1}, “h”:{“min”:0,“scale”:0,“unit”:"",“max”:360,“step”:1},“s”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1},“v”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1}}"
},
{
“code”: “power_memory”,
“dp_id”: 33,
“type”: “Raw”,
“values”: “{}”
}
],
“status”: [
{
“code”: “switch_led”,
“dp_id”: 20,
“type”: “Boolean”,
“values”: “{}”
},
{
“code”: “work_mode”,
“dp_id”: 21,
“type”: “Enum”,
“values”: “{“range”:[“white”,“colour”,“scene”,“music”]}”
},
{
“code”: “bright_value_v2”,
“dp_id”: 22,
“type”: “Integer”,
“values”: “{“min”:10,“max”:1000,“scale”:0,“step”:1}”
},
{
“code”: “temp_value_v2”,
“dp_id”: 23,
“type”: “Integer”,
“values”: “{“min”:0,“max”:1000,“scale”:0,“step”:1}”
},
{
“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}}}"
},
{
“code”: “countdown_1”,
“dp_id”: 26,
“type”: “Integer”,
“values”: “{“unit”:“s”,“min”:0,“max”:86400,“scale”:0,“step”:1}”
},
{
“code”: “music_data”,
“dp_id”: 27,
“type”: “Json”,
“values”: “{“change_mode”:{“range”:[“direct”,“gradient”]}, “bright”:{“min”:0,“scale”:0,“unit”:”",“max”:1000,“step”:1}, “temperature”:{“min”:0,“scale”:0,“unit”:"",“max”:1000,“step”:1}, “h”:{“min”:0,“scale”:0,“unit”:"",“max”:360,“step”:1},“s”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1},“v”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1}}"
},
{
“code”: “control_data”,
“dp_id”: 28,
“type”: “Json”,
“values”: “{“change_mode”:{“range”:[“direct”,“gradient”]}, “bright”:{“min”:0,“scale”:0,“unit”:”",“max”:1000,“step”:1}, “temperature”:{“min”:0,“scale”:0,“unit”:"",“max”:1000,“step”:1}, “h”:{“min”:0,“scale”:0,“unit”:"",“max”:360,“step”:1},“s”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1},“v”:{“min”:0,“scale”:0,“unit”:"",“max”:255,“step”:1}}"
},
{
“code”: “power_memory”,
“dp_id”: 33,
“type”: “Raw”,
“values”: “{}”
}
]
},
“success”: true,
“t”: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
“tid”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
}

So my question is what goes where??
I’ve experimented and at least HA knows it’s a light not a switch, and I see the Color wheel, but still doesn;t change colors or dimm…

Good day,
So first thing is the “original Localtuya” integration wont work if your device is new or on new firmware. Check this thread. Someone has forked it and it adds the 3.4 protocol.

However, in my case I added the “new” integration and I have a light with same dp-id as yours and whilst I was able to add it, i cant control it.
I can only turn it off.

So unfortunately tuya seems to be “broken”

How do I add the pd-id’s as I am getting the same errors as others in the thread, I added my first 4 switches no problem, but now each and every switch I try to add I am getting the error.

I followed the steps to get the dp-ids from the API, but no idea on how to manually set them in Home Assistant.
Thanks in advance!

when you’re doing the config flow part, there’s a space for ‘DPS’.
you add them there like this: 20,21,22,23,24

1 Like

Yikes… not good.
So far I’ve not been successful getting any of my 17 devices to fully run Localtuya, only simple switches but thinks lights are switches. I’ve watched many videos but the DP ids seem Overly complicated. That said I’m still learning Localtuya but wondering if it’s worth it. LoL
Curious, is this because Tuya doesn’t want their devices to run locally, or because they are simply upgrading their devices with more added features.

@PCman yes, LocalTuya is rather involved because both Tuya and FOSS are intended for professionals or experienced amateurs. Bottom line is that you are free to not use it if you choose.

I also found it confusing, but once the pieces fall into place it’s not so bad. I made a document summarising the details of my Tuya devices, and the first thing was to make a table of the dp_ids from the Tuya website, like:

code            dp_id   type       values
switch_led,       20,   Boolean,
work_mode,        21,   Enum,      "white”,“colour”,“scene”,“music”
bright_value_v2,  22,   Integer,   10-1000
countdown_1,      26,   Integer,   0-86400

Note that there are actually 2 lists… “Functions” are the dp_ids you can change the values of, and most of them (and a few others maybe) are also listed under the “status” section.

You say it’s a light … but dp_id 27 is “music_data”, wow that’s odd. A christmas fairy light set ?

Anyway LocalTuya is somewhat odd in having to repeat part of the process for each dp_id you want to view/change for a device.

  1. select the device to add or edit, enter its name, local_key, etc
  2. The first time you see the “Entity Type selection” box, you just select the base entity type (probably a “switch”) and [Submit]
  3. configure details of that entity - dp_id, friendly name, etc
  4. this is the tricky bit - you will be presented the Entity Type selection" window again, and it also has a ticked check box “Do not add any more entities”. UN-tick the box and select the entity type for the next dp_id you wish to create a HA entity for, click [submit] and go back to step 3. Repeat until all entities have been created.

For a more complete description see message 50 in Energy consumption and Arlec Grid Connect (Tuya) smart plug

Yes, it is clunky, but LocalTuya does not know every device and what dp_ids it has, and this approach provides flexibility. I just wish the box defaulted to un-ticked.

Oh, and lights are essentially switches - the most basic light only allows you to turn_on and turn_off.

@juan11perez I tried entering dp_ids like that, but found that didn’t give easy access to them.

@PCman Tuya are in business of providing firmware to device manufacturers, so yes they do want cloud control. And yes their platform makes it possible for them and their clients (device manufacturers) to add new dp_ids for whatever new features … like most of the ones in your lights. I assume you didn’t get a comprehensive manual listing all the options :wink:

3 Likes

Hi, just trying to view dpids for my switch/lights
But why are the dpid not listed?

Get Device Specification Attribute:

{
  "result": {
    "category": "kg",
    "functions": [
      {
        "code": "switch_1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "relay_status",
        "type": "Enum",
        "values": "{\"range\":[\"power_off\",\"power_on\",\"last\"]}"
      },
      {
        "code": "cycle_time",
        "type": "String",
        "values": "{}"
      },
      {
        "code": "random_time",
        "type": "String",
        "values": "{}"
      },
      {
        "code": "switch_inching",
        "type": "String",
        "values": "{}"
      }
    ],
    "status": [
      {
        "code": "switch_1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "relay_status",
        "type": "Enum",
        "values": "{\"range\":[\"power_off\",\"power_on\",\"last\"]}"
      },
      {
        "code": "cycle_time",
        "type": "String",
        "values": "{}"
      },
      {
        "code": "random_time",
        "type": "String",
        "values": "{}"
      },
      {
        "code": "switch_inching",
        "type": "String",
        "values": "{}"
      }
    ]
  },
  "success": true,
  "t": 1670556389606,
  "tid": "4546eb01777111ed9b174e03f8c0f22a"
}

Yep, that gave me quite a bit of grief !
There are actually two entries in that menu with the same name - except one uses initial capital letters and the other doesn’t.
Screenshot from 2022-12-09 14-40-01

In the API Explorer window’s leftmost menu, open “Smart Home Device System” then “Device Control” (near the bottom) menu and select “Get Device Specific…” (note the capital letters).

6 Likes

Thanks! Got the dpids now

Thanks for the tip, I have a fan which has two modes, normal and natural. Normal just means it operates at the set speed (1-6) and natural means it automatically changes up and down in speed to feel more like a real breeze.

Nothing in the Get Device Specific Attribute API result relates to this function. So does that mean it is not a DP and instead a function of something else?

Edit, Actually, I can see it when configuraing the device so i know it is DP 2. I think the issue is the when i choose FAN local tuya does not have a field available for such a function, that is why i can’t add it, i have to add it as a seperate entity.

Have a good laugh Phil … post christmas i bought a set of wifi LED Fairy lights which are Tuya category “dj” like yours … and you guessed it, I’m now struggling to configure them in LocalTuya.

I found some more detail on the DP_IDs, at Function Definition of Lighting Products-Tuya IoT Development Platform-Tuya Developer – including specifics on interpreting long strings including dp_id 25 in your image - but they just don’t map to the LocalTuya fields.

hi i used localtuya for my oil heater

i can change the temperature and switch it to off and on

with:

template - climate
target temperature
value: 22

current temperature
value: 22

Temperature step
1

precision
1

hvac mode set
true/false

hvac mode dp
value true

hvac current action set
heating/no_heating

temperature unit
clesius

traget precison
1

and template switch for off and on

I would like to

access the thermostat

I’ve already tried the template sensor, but it always shows the current heating value

and what would also be cool is it is possible to switch the radiator to eco and comfort (800 watt and 2500 watt) but unfortunately i haven’t managed to do that either

is there a way to get the local_key without the API?

The good think about the Tuya DP-ID’s is they seem to be consistent accros their product. I have only worked with lights and switches. I have compiled a list of the dp-id’ definitions for the products I have.

You can determine the dp-id’s that your Tuya device supports by going to Tuya IoT Platform and entering your devidceid → select search and then select in the “Please input function point ID” box.

One issue I found is that sometimes TuyaLocal does not present the correct availiable dp-id’s → screwed…

Colour tempurature does not work correctly for a Tuya LED strip model 50053 - V2. It does not work properly in the Tuya AP either…

20 switch_led True/False Light is on or off
21 Work/Colour Mode
22 Brightness 0-1000
23 Colour Temperature White/Colour/Mood
24 Colour 2700/6500
25 Mode/Scene Night, Read, Meeting, Leasure, Soft, Rainbow, Shine, Beautiful These will step through the defined scenes regardless of name
26 Timer
27
28 Adjust
32 Wake up
33 Power Off Memory
34 Do Not Disturb
210 Vacation

name Vacuum Sealer Craft room light Table Lamp Bed Ciera Lamp Basement Hallway
category cz cz dj dj dj dj
id eb02c08ea9197d6a7f7vxx eb0607f4a1ce360bcbib4y eb10fd114b51e164c5kalg 47233246e868e76dd695 85481764bcddc2a16f29 750344232cf4326fbc4e
biz_type 18 18 18 18
local_key Hidden Hidden Hidden Hidden Hidden Hidden
category_name Socket Socket Light LED Strip Light Light
product_id kneovghpxlnyvhst kneovghpxlnyvhst fruqqwrkm5wlqizu 9fuu81prbj6rubyr gobeqoj9pb4svj1e pu4xpsh4drb0qamb
product_name 50207 50207 34228 50053 - V2 34202 - V1 Colour Bulb
model Potek - 50239-costco Potek - 50239-costco Globe WBLC5 - Litech V2 34202: Kevin New YAMAO PID RGBW
Config
id or dp_id 1 1 Tuya_Light_34228.png Tuya_Light_50053-V2 .png Tuya_Light_34202-V1.png Tuya_Light_34202-V1.png
Tuya dp-id’s 1,9,38,40,41,42,43,44 1,9,38,40,41,42,43,44 20,21,22,23,32,33,34,210 20,21,22,24,25,26,28 20,21,22,23,24,25,26,28 20,21,22,23,24,25,26,28
TuyaLocal 5.0 id’s Same Same 20,21,22,23,24,25,26,34 20,21,22,23,24,25,26 20,21,22,24,25,26 20,21,22,24,25,26
3 Likes

Dumb question - don’t see it… Is there a way to neatly transfer a scene as defined in the app? So if I changed the default “Night” scene to be a flashing two colors. Or do we have to do that somehow within the YAML?

Thanks

For my vacuum cleaners I would like to show cleaning_time and cleaning_area.
In the IOT Tuya Platform I saw the dps are 119 and 120.

{
  "result": {
    "category": "sd",
    "functions": [
      {
        "code": "power",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "power_go",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "direction_control",
        "dp_id": 3,
        "type": "Enum",
        "values": "{\"range\":[\"forward\",\"backward\",\"turn_left\",\"turn_right\"]}"
      },
      {
        "code": "mode",
        "dp_id": 5,
        "type": "Enum",
        "values": "{\"range\":[\"standby\",\"smart\",\"wall_follow\",\"single\",\"point\"]}"
      },
      {
        "code": "switch_charge",
        "dp_id": 101,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "seek",
        "dp_id": 103,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "volume_set",
        "dp_id": 111,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      }
    ],
    "status": [
      {
        "code": "power",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "power_go",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "direction_control",
        "dp_id": 3,
        "type": "Enum",
        "values": "{\"range\":[\"forward\",\"backward\",\"turn_left\",\"turn_right\"]}"
      },
      {
        "code": "mode",
        "dp_id": 5,
        "type": "Enum",
        "values": "{\"range\":[\"standby\",\"smart\",\"wall_follow\",\"single\",\"point\"]}"
      },
      {
        "code": "status",
        "dp_id": 15,
        "type": "Enum",
        "values": "{\"range\":[\"standby\",\"goto_charge\",\"charging\",\"charge_done\",\"cleaning\",\"sleep\"]}"
      },
      {
        "code": "switch_charge",
        "dp_id": 101,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "seek",
        "dp_id": 103,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "electricity_left",
        "dp_id": 104,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "clean_time",
        "dp_id": 109,
        "type": "Integer",
        "values": "{\"unit\":\"min\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "clean_area",
        "dp_id": 110,
        "type": "Integer",
        "values": "{\"unit\":\"㎡\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "volume_set",
        "dp_id": 111,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "edge_brush",
        "dp_id": 112,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "roll_brush",
        "dp_id": 113,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "filter",
        "dp_id": 114,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "total_clean_time",
        "dp_id": 119,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "total_clean_area",
        "dp_id": 120,
        "type": "Integer",
        "values": "{\"unit\":\"㎡\",\"min\":0,\"max\":10000000,\"scale\":0,\"step\":1}"
      }
    ]
  },
  "success": true,
}

Bildschirm­foto 2023-03-23 um 15.45.55
image

However, I have no DPS with 119 and 120 in the assignment.

What can I do?