DDF support Tuya manufacturer specific cluster & How to know which datapoints a Tuya device provides? - dresden-elektronik/deconz-rest-plugin GitHub Wiki

DDF support Tuya manufacturer specific cluster

Using a specific tuya function, we can read, parse and write from/to Tuya manufacturer specific cluster (0xEF00) using a Device Description File (DDF : See DDF-cheat-sheet)

Example: MoesGo Smart Dimmer Module (_TZE200_e3oitdyu): PR #5869

image

  1. The parse function needs to specify the datapoint dpid to be parsed. The actual data type is part of the message and processed accordingly.

  2. The write function further has to specify the data type via dt with a subset of ZCL data types:

      bool           0x10
      s32 value      0x2b
      enum           0x30
      8-bit bitmap   0x18
      16-bit bitmap  0x19
      32-bit bitmap  0x1b

In C++ code the write function is best used by the StateChange class, as this function does for REST-API PUT /lights/<id>/state endpoint when settings {"on": bool, "bri": number}. This has the benefit that if commands didn't workout they are repeated automatically.

  1. The read function is special and must only be specified on one item (here state/on). It doesn't actually read a single value but triggers the Tuya device to report all datapoints.

The read and parse functions are available via DDF editor, write will be added eventually (need a text editor at this time to add write function into a DDF file)

image

How to know which datapoints a Tuya device provides?

Exec the Data Query command in the Cluster Info panel of the Tuya specific cluster (0xEF00) :

image

After a few seconds the debug log shows incoming reports for all datapoints (log .

image

Note the type here is the Tuya data type not the ZCL data type.

      raw     0x00
      bool    0x01
      value   0x02
      string  0x03
      enum    0x04
      bitmap  0x05

Tuya magic sequence in DDF

Some Tuya based devices need a special reading attributes sequence from Basic Cluster to "unlock" some features (reporting some values, addressing some endpoint individualy, etc ...).

This can be accomplish with DDF by including the specific item config/tuya_unlock into only one of the subdevices that the DDF describes. This item is refreshed every 86400 seconds (a day).

        {
           "name":"config/tuya_unlock"
        }