Discovering LocalTuya keys and DP's

As others have commented before, if you’re trying to setup LocalTuya as I’ve just been doing, you can discover the device id’s and local keys through the tuya iot platform website. Once you’ve got your device ids from the Devices tab in your project, you can use the API Explorer to find your keys. If you go to the Device Management section, it’s now called Query Device Details, using a device ID. This will show you your local key. However, it’s actually more useful that that. If you go to the Device Control section and Query Properties of a device, it returns JSON which actually lists out all of the DPs, and tells you which is which.

"result": {
    "properties": [
      {
        "code": "switch_1",
        "custom_name": "",
        "dp_id": 1,
        "time": 1688541767048,
        "value": false
      },
      {
        "code": "countdown_1",
        "custom_name": "",
        "dp_id": 9,
        "time": 1688541767048,
        "value": 0
      },
      {
        "code": "relay_status",
        "custom_name": "",
        "dp_id": 38,
        "time": 1688541767077,
        "value": "memory"
      }

If you then go to Device Control (Standard Instruction Set) section, it’ll even tell you the correct values for a select list for example if you do a “Get Specifications and Properties”

      {
        "code": "relay_status",
        "desc": "{\"range\":[\"power_off\",\"power_on\",\"last\"]}",
        "name": "上电状态",
        "type": "Enum",
        "values": "{\"range\":[\"power_off\",\"power_on\",\"last\"]}"
      },

So, no guesswork required setting up the DPs in LocalTuya :slight_smile:

Hope that’s helpful.

6 Likes

GREAT info

You saved my life

THANK YOU!

If someone is experiencing with cloud trial expiration issue, I have found an article which explains how to get the DPs ID using free Tuya Smart Home Basic Service. Title of article is Getting Tuya Device ID, Local Key and DP ID using Tuya Smart Home Basic Service.

1 Like

Hey,

Do you have any instructions on how to actually add these so they are usable entities in Home Assistant? I’m searching for a guide of video on how to do this but can’t find a lot of usefull info.

Thanks!

These are useful when you’re using LocalTuya or TuyaLocal, rather than the built in Tuya integration. LocalTuya lets you add custom DP_IDs when you setup a device ( rospogrigio/localtuya: local handling for Tuya devices (github.com)) and TuyaLocal make-all/tuya-local: Local support for Tuya devices in Home Assistant (github.com) also let’s you create config files so that unknown/unrecognised devices can be fully support. Both of them of course also offer local control. I switched over to TuyaLocal quite a while back, created the custom config files for devices that weren’t recognised using the info from above and it all works perfectly.

1 Like

Thanks a lot for the information! Would you recommend TuyaLocal over LocalTuya? I tried to add custom DPs in LocalTuya but found it rather cumbersome since you have to specify all types, values etc.

Does this work better in TuyaLocal?
I will give it a try tomorrow. :slight_smile:

Yes, my personal preference is TuyaLocal. When I moved over, I found there was less delay in switching, and I really like the ability to define my own device configs so I can specify all of the correct dps etc., which TuyaLocal then just recognises when it sees that device again. Nothing wrong with LocalTuya, but for me TuyaLocal works better. It’s also more active I think - for example, it now has the same “scan the QR” code approach as the core Tuya int uses.

1 Like

You can see docs on creating a custom device at tuya-local/custom_components/tuya_local/devices/README.md at main · make-all/tuya-local (github.com) along with hundreds of currently supported device configs.

1 Like

Hi psketch, is there any explanation how to add an unsupported device to Tuya Local ? I have Keys, DPIs and want to add a not supported device now. Where must I add the Keys and DPIs now ?

tuya-local/custom_components/tuya_local/devices/README.md at main · make-all/tuya-local (github.com)

I’d suggest taking a look at a similar device to yours in the existing config, and then just tweaking accordingly.