jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
923 stars 165 forks source link

Unhiding hidden Cloud DPs #280

Closed uzlonewolf closed 1 year ago

uzlonewolf commented 1 year ago

While looking into #278 I found a post in another project talking about how they needed to make sure the devices in the cloud project were configured for "Standard Instruction" instead of "DP Instruction" under "Control Instruction Mode." https://github.com/Xenomes/Domoticz-TinyTUYA-Plugin/issues/15#issuecomment-1419739027 I thought, you know, for our needs we might actually want to switch to that (much more raw) "DP Instruction." The attribute map at the bottom of the setting page looked promising as well with the missing DPs clearly not mapped to any "Standard Instruction" but every last one had a mapping when set to "DP Instruction." After switching to "DP Instruction" and waiting a few hours, guess what? The cloud calls now return every single DP for my thermostats and have accurate types, values, and states to boot!

So, if you want the Cloud calls to return *every* DP, change your Control Instruction Mode!

jasonacox commented 1 year ago

Is there a global way to set that? It looks like it is "per device" setting:

uzlonewolf commented 1 year ago

Not that I've found, which is annoying since my list of device types is rather long.

jasonacox commented 1 year ago

Here is what I'm thinking about for documentation - It could stay in this issue we reference or in a Discussion. What do you think? Feel free to edit.

Tuya Cloud - DP Instruction Mode

How to get the full set up DPS values from Tuya Cloud.

This how-to will show you how to activate “DP Instruction” mode for your Tuya devices when using Tuya Cloud to pull data. This will result in getting the full list of DPS values and their properties for your devices.

Step 1 - Log in to your account on iot.tuya.com

Step 2 - Navigate to "Cloud" -> "Development" then select your project.

Step 3 - Select "Devices" tab.

image

Step 4- Select the device types and click the the "pencil icon" to edit.

image

Step 5 - Select the "DP Instruction" box and "Save Configuration"

image

There doesn't appear to be a way to globally set "DP Instruction" for all device types. You will need to select each device type and repeat the above step.

Step 6 - Use TinyTuya to access the full set of DPS

After 12-24 hours, you should now be able to poll the Tuya Cloud using TinyTuya to get the full list of DPS properties and values.

import tinytuya

# Connect to Tuya Cloud
c = tinytuya.Cloud(
        apiRegion="us", 
        apiKey="xxxxxxxxxxxxxxxxxxxx", 
        apiSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
        apiDeviceID="xxxxxxxxxxxxxxxxxxID")

# Display list of devices
devices = c.getdevices()
print("Device List: %r" % devices)

# Select a Device ID to Test
id = "xxxxxxxxxxxxxxxxxxID"

# Display Properties of Device
result = c.getproperties(id)
print("Properties of device:\n", result)

# Display Status of Device
result = c.getstatus(id)
print("Status of device:\n", result)
uzlonewolf commented 1 year ago

Updated Step 2. to include -> "Development" and changed "a few hours" to "12-24 hours" (I really should time this). Otherwise that looks great!

Not sure why I didn't make this a Discussion to begin with, I'm going to blame it on being really tired. Edit: I see Gihub has a "Convert to discussion" option, but I don't know what "close and lock" is going to do (I assume it just means the issue and not the new discussion, but you never know).

jasonacox commented 1 year ago

Thanks @uzlonewolf - and please, don't get sick... get some rest!! 🤗

I see Gihub has a "Convert to discussion" option

No rush, but go ahead and try it. We can always recreate this if needed.