rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.71k stars 530 forks source link

Some DPs (enum) do now show when creating entities #1419

Open cibernox opened 1 year ago

cibernox commented 1 year ago

The problem

This happens using a smart 8 zone sprinkler irrigation controller, model number DP-WBS01. Some DP that are visible in the API explorer don't seem to be visible when adding entities. In particular seem that some that contain Enums are not displayed. I am focusing on the irrigation_mode, which determines if zones are watered in sequence or all simultaneously.

This is the payload from Device Control > Get Device Specification Attribute (check near the bottom)

{
  "result": {
    "category": "ggq",
    "functions": [
      {
        "code": "switch_1",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_2",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_3",
        "dp_id": 3,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_4",
        "dp_id": 4,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_5",
        "dp_id": 5,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_6",
        "dp_id": 6,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_7",
        "dp_id": 7,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_8",
        "dp_id": 8,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "dp_id": 13,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_2",
        "dp_id": 14,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_3",
        "dp_id": 15,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_4",
        "dp_id": 16,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_5",
        "dp_id": 17,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_6",
        "dp_id": 18,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_7",
        "dp_id": 19,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_8",
        "dp_id": 20,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "weather_delay",
        "dp_id": 37,
        "type": "Enum",
        "values": "{\"range\":[\"24h\",\"48h\",\"72h\",\"cancel\"]}"
      },
      {
        "code": "normal_timer",
        "dp_id": 38,
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "water_control",
        "dp_id": 40,
        "type": "Enum",
        "values": "{\"range\":[\"on\",\"off\"]}"
      },
      {
        "code": "smart_weather",
        "dp_id": 41,
        "type": "Enum",
        "values": "{\"range\":[\"sunny\",\"cloudy\",\"rainy\",\"snowy\"]}"
      },
      {
        "code": "weather_switch",
        "dp_id": 42,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "control_skip",
        "dp_id": 43,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "irrigation_mode",
        "dp_id": 44,
        "type": "Enum",
        "values": "{\"range\":[\"order\",\"together\"]}"
      },
      {
        "code": "irrigation_time_all",
        "dp_id": 45,
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "irrigation_timing_all",
        "dp_id": 46,
        "type": "String",
        "values": "{\"maxlen\":255}"
      }
    ],
    "status": [
      {
        "code": "switch_1",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_2",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_3",
        "dp_id": 3,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_4",
        "dp_id": 4,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_5",
        "dp_id": 5,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_6",
        "dp_id": 6,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_7",
        "dp_id": 7,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_8",
        "dp_id": 8,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "dp_id": 13,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_2",
        "dp_id": 14,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_3",
        "dp_id": 15,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_4",
        "dp_id": 16,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_5",
        "dp_id": 17,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_6",
        "dp_id": 18,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_7",
        "dp_id": 19,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_8",
        "dp_id": 20,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_1",
        "dp_id": 25,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_2",
        "dp_id": 26,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_3",
        "dp_id": 27,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_4",
        "dp_id": 28,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_5",
        "dp_id": 29,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_6",
        "dp_id": 30,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_7",
        "dp_id": 31,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "use_time_8",
        "dp_id": 32,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "weather_delay",
        "dp_id": 37,
        "type": "Enum",
        "values": "{\"range\":[\"24h\",\"48h\",\"72h\",\"cancel\"]}"
      },
      {
        "code": "normal_timer",
        "dp_id": 38,
        "type": "String",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "work_state",
        "dp_id": 39,
        "type": "Enum",
        "values": "{\"range\":[\"manual\",\"auto\",\"idle\"]}"
      },
      {
        "code": "water_control",
        "dp_id": 40,
        "type": "Enum",
        "values": "{\"range\":[\"on\",\"off\"]}"
      },
      {
        "code": "smart_weather",
        "dp_id": 41,
        "type": "Enum",
        "values": "{\"range\":[\"sunny\",\"cloudy\",\"rainy\",\"snowy\"]}"
      },
      {
        "code": "weather_switch",
        "dp_id": 42,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "control_skip",
        "dp_id": 43,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "irrigation_mode",          <-------------------------------------------------------------this one
        "dp_id": 44,
        "type": "Enum",
        "values": "{\"range\":[\"order\",\"together\"]}"
      },
      {
        "code": "irrigation_time_all",
        "dp_id": 45,
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "irrigation_timing_all",
        "dp_id": 46,
        "type": "String",
        "values": "{\"maxlen\":255}"
      }
    ]
  },
  "success": true,
  "t": 1685745991115,
  "tid": "514548dc019711eea795ce4cada2c678"
}

It doesn't seem to be listed when running tuyadebug's test.py command:

    DPS [1] VALUE [False]
    DPS [2] VALUE [False]
    DPS [3] VALUE [False]
    DPS [4] VALUE [False]
    DPS [5] VALUE [False]
    DPS [6] VALUE [False]
    DPS [7] VALUE [False]
    DPS [8] VALUE [False]
    DPS [13] VALUE [0]
    DPS [14] VALUE [0]
    DPS [15] VALUE [0]
    DPS [16] VALUE [0]
    DPS [17] VALUE [0]
    DPS [18] VALUE [0]
    DPS [19] VALUE [0]
    DPS [20] VALUE [0]
    DPS [25] VALUE [0]
    DPS [26] VALUE [0]
    DPS [27] VALUE [0]
    DPS [28] VALUE [0]
    DPS [29] VALUE [0]
    DPS [30] VALUE [0]
    DPS [31] VALUE [0]
    DPS [32] VALUE [0]
    DPS [37] VALUE [cancel]
    DPS [38] VALUE [AQU3AX8AAAAAAAQCBwUFAgEAAAAAAAIBiwF/AAAAAAAFAgcFBAIBAAAAAAA=]
    DPS [39] VALUE [idle]
    DPS [42] VALUE [False]
    DPS [46] VALUE [AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA]

Maybe this is normal, but I couldn't find any info or explanation on why the attribute with DP 44 is not displayed. The device uses protocol 3.3.

Environment

DP dump

    DPS [1] VALUE [False]
    DPS [2] VALUE [False]
    DPS [3] VALUE [False]
    DPS [4] VALUE [False]
    DPS [5] VALUE [False]
    DPS [6] VALUE [False]
    DPS [7] VALUE [False]
    DPS [8] VALUE [False]
    DPS [13] VALUE [0]
    DPS [14] VALUE [0]
    DPS [15] VALUE [0]
    DPS [16] VALUE [0]
    DPS [17] VALUE [0]
    DPS [18] VALUE [0]
    DPS [19] VALUE [0]
    DPS [20] VALUE [0]
    DPS [25] VALUE [0]
    DPS [26] VALUE [0]
    DPS [27] VALUE [0]
    DPS [28] VALUE [0]
    DPS [29] VALUE [0]
    DPS [30] VALUE [0]
    DPS [31] VALUE [0]
    DPS [32] VALUE [0]
    DPS [37] VALUE [cancel]
    DPS [38] VALUE [AQU3AX8AAAAAAAQCBwUFAgEAAAAAAAIBiwF/AAAAAAAFAgcFBAIBAAAAAAA=]
    DPS [39] VALUE [idle]
    DPS [42] VALUE [False]
    DPS [46] VALUE [AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA]

Provide Home Assistant traceback/logs

No logs.

Additional information

I am happy to help debug if I can, I know enough python to be dangerous. But possibly this is not a bug but a limitation of tuya's local API.

Steve2017 commented 1 year ago

I’ve had a similar issue when adding an Arlec smart switch. (PC191HA) I had three that showed current, energy and voltage as DPs/sensors. I have just added a 4th that had been sitting in the cupboard for 6 months and it will not show the DPs. The switch works as expected.

The information is there in the Tuya app and shows up in the attributes but the DPs (18,19 and 20) are not listed in the entities. I recall they are shown in the Tuya IOTPlatform.

When I compare the debug log, the others show the DPs but this one has a very simple listing.

If I use the “official” Tuya integration, all the sensors are there.