Localtuya configuration of entities for Socket devices (type cz)

Hi,

For those who are also struggling to get the tuya socket devices at work in localtuya and also want to use some of the entities which are not automatically created, I’ve compiled a list of useful entities with the corresponding DP IDs and parameters. Some of the dps_string parameters I’m not sure what they represent and I’ve left blank, maybe someone who knows what their purpose is could help complete this list. The parameters are collected from the tuya IoT platform, which was also used to retrieve the Local Keys.

There are plenty of youtube video’s decribing this process to get the device ID’s and Local Keys. The one which took me to the right place and process was: https://www.youtube.com/watch?v=vq2L9c5hDfQ. Some of the menu’s on the tuya developer site have changed a bit but you should be able to find the right place. Pease make very sure in this process you select the right developer cloud server! Make sure the one you select is compatible with the app on your phone which is requried for the process.

I’ve gone through this process because I, by accident purchased a bunch of the wrong type of socket (Eightree ET20), I’m not sure if the DP’s listed below will also work for other tuya ‘cz’ type of sockets. Finally I got them to work as I need. All described parameters are tested and work, although I have not calibrated the sensors.

After you’ve created the devices in the localtuya integration you can add the missing entities in Homeassistant by:

  1. opening the Settings - Devices&Services - Local Tuya (assume this is installed) and select Configure.
  2. in the popup you select Edit a device (2nd option)
  3. select the device (ID) to which you want to add one or more of the entities from the table below.
  4. in the next screen you do not need to edit anything other than to tick the box at the bottom of the popup (“Add more entities in ‘edit device’ mode”)
  5. IMPORTANT: select the right type of entity (third column in the table below), AND un-select the tickbox at the bottom of the popup (otherwise the process of adding an entity is ended before you actually created) and click Send
  6. in the first field select the DP ID (first column of table) of the entity you want to create and complete the other fields. Parameters in this step can be added or modified later as well.
  7. if all parameters are completed, click Send. Now you are prompted for the type of a new entity (step 5 above). At this step you can either continue adding entities (don’t forget to unselect the checkbox at the bottom of the popup) or end the process (leave the checkbox ticked) and click Send.
  8. you may have to restart Homeassistant as some entities may not work without a restart.

Eightree Smart switch ET20 (socket)
Tuya DP id’s and codes, retrieved from the tuya developers documentation site

DP ID DP code Type Scale Step Min Max Select options Unit or Friendly Select options description
1 switch_1 switch Switch
9 countdown_1 numeric 0 1 0 86400 S Count down
17 add_ele* sensor 0.1 0 50000 kWh Power consumption (kWh)
18 cur_current sensor 0 30000 mA Current (mA)
19 cur_power sensor 0.1 0 80000 W Watt (W)
20 cur_voltage sensor 0.1 0 5000 V Voltage (V)
21 test_bit*
22 voltage_coe* sensor
23 electric_coe* sensor
24 power_coe* sensor
25 electricity_coe* sensor
26 fault*
38 relay_status select off;on;memory On;Off;Restore from last state Startup status
39 light_mode select relay,pos,none,on Follow relay;Inverse;Off;On Light status
40 child_lock switch Child lock
41 cycle_time* string
42 random_time* string
44 switch_inching* string
46 overcharge_switch switch Overheating protection

*These DPs I have not configured as their use is not completely clear for me. Especially DP ID 17 is a bit puzzling. In the documentation of Tuya developer site it is said it represents the cumulative power (kWh) consumed. The entity howerve as a constant value and does not actually change.

If someone knows what the missing DPs are used for and how they should be configured it could be useful to complete this table.

Hope this is helpful for others trying to configure tuya sockets.

1 Like

Thanks, it helped. You can also retrieve DPs from iot.tuya.com

But select options from the link differ from yours and yours actually work, for example relay_status shows “range;power_off;power_on;last” from iot.tuya, which doesn’t work.