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

@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:

4 Likes