Including standard Tuya "magic spell" sequence during joining

Ha yes right, but so much comment on the code.

// no idea why, but we have to wait, otherwise the next request will fail!

Hu …, the DDF make the request every 24h, can reduce the time for test, if it fail the first time, can work the second one.

            // set reporting interval of genOnOff to max to "disable" it
            // background: genOnOff reporting does not respect timer or button, that makes the on/off reporting pretty unreliable
            // the device is reporting it's state change anyway via tuya DPs, so we  just lose the continuous state report
            await reporting.onOff(endpoint, {max: 0xFFFF});

Need to do same on the DDF ?

@sinus61 can you share your actual DDF, and the “feature” you are trying to have ? Duration time can be possible with config/duration, but not sure, the legacy code need to never use this field.

I’ve added some changes to the PR from ChrisHae, this is working now for me. Setting the duration time is possible und you get back the time left. I think the PR for z2m added to many stuff I don’t need in the device like weektimers, I can do this better from my home automation.

It don’t have the Tuya magic spell inside, but I have tried with that also. Makes it sense to have it in the DDF?

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE200_htnnfasr",
  "modelid": "TS0601",
  "vendor": "LIDL",
  "product": "Smart watering timer",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_ON_OFF_OUTPUT",
      "restapi": "/lights",
      "uuid": [
        "$address.ext",
        "0x01"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "state/on",
          "refresh.interval": 300,
          "read": {
            "fn": "tuya"
          },
          "write": {
            "dpid": 1,
            "dt": "0x10",
            "eval": "Item.val == 1 ? 1 : 0;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 1,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          }
        },
        {
          "name": "state/reachable"
        }
      ]
    },
    {
      "type": "$TYPE_OPEN_CLOSE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0500"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "refresh.interval": 84000,
          "read": {
            "at": "0x0001",
            "cl": "0x0000",
            "ep": 1,
            "fn": "zcl"
          },
          "parse": {
            "at": "0x0001",
            "cl": "0x0000",
            "ep": 1,
            "fn": "zcl",
            "script": "tuya_swversion.js"
          }
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
		{
          "name": "config/battery",
          "parse": {
            "dpid": 11,
            "eval": "Item.val = Attr.val * 50;",
            "fn": "tuya"
          },
          "default": 100
        },		
        {
          "name": "config/duration",
          "write": {
            "dpid": 5,
            "dt": "0x2b",
            "eval": "Attr.val = Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 5,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          }
        },		
        {
          "name": "config/locked",
          "write": {
            "dpid": 109,
            "dt": "0x10",
            "eval": "Item.val == 1 ? 1 : 0;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 108,
            "eval": "Item.val == 1 ? 0 : 1;",
            "fn": "tuya"
          },
          "default": false
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/seconds_remaining",
          "parse": {
            "dpid": 6,
            "eval": "Item.val = Attr.val * 60;",
            "fn": "tuya"
          }
        }		
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0006",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x10",
          "min": 1,
          "max": 300
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0006",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x10",
          "min": 1,
          "max": 300
        }
      ]
    }
  ]
}

Good question ^^, you are the better one to answer.
If all is working without, no, can depend of version, some version probably need it (I think it’s for that the code is present on Z2M) but as you can’t test it, better to avoid it, a future user with issues can add itself the code to test.

Quick question, this DDF only specifies read and parse section. How/Why is it sending a magic sequence to the device without a write section? Or am I misunderstanding something completely here?

Hi,

Because there is nothing to « send » to the device. The order in which reading some attributes is done is the « unlock » :wink:

Hi, thanks for the explanation.