WOOX R7049 smoke detector

I am trying to create a DDF for the WOOX R7049 smoke detector, see below. I used the code in tuya.cpp as far as possible, and at least test indication works. However, for the “lowbattery” attribute, DP 14 needs to be read out, any idea how to build this in?

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE200_aycxwiau",
  "modelid": "TS0601",
  "vendor": "WOOX",
  "product": "Smart Smoke Alarm R7049",
  "sleeper": true,
  "status": "Gold",
  "path": "/devices/Woox_smart_smoke_alarm_r7049.json",
  "subdevices": [
    {
      "type": "$TYPE_FIRE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0xef00"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0051",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0xEF00"
        ]
      },
      "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": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/errorcode",
          "awake": true,
          "parse": {
            "dpid": 11,
            "eval": "Item.val = String(Attr.val);",
            "fn": "tuya"
          }
        },
        {
          "name": "state/fire",
          "awake": true,
          "parse": {
            "dpid": 1,
            "eval": "Item.val = (Attr.val == 0 ? true : false);",
            "fn": "tuya"
          },
          "default": false
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lowbattery",
          "description": "True when the device battery runs low."
        },
        {
          "name": "state/test",
          "awake": true,
          "parse": {
            "dpid": 8,
            "eval": "Item.val = (Attr.val == 0 ? false : true);",
            "fn": "tuya"
          },
          "default": false
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0xEF00"
    }
  ]
}

Update: seems to work now.

                    {
    "config": {
        "on": true,
        "reachable": true
    },
    "ep": 1,
    "etag": "2a0ccb96b42eca71aa614fbfb6d8db33",
    "lastannounced": "2023-11-18T11:37:48Z",
    "lastseen": "2023-11-18T11:37Z",
    "manufacturername": "_TZE200_aycxwiau",
    "modelid": "TS0601",
    "name": "Fire 526",
    "state": {
        "errorcode": "0",
        "fire": false,
        "lastupdated": "2023-11-18T11:38:06.927",
        "lowbattery": false,
        "test": false
    },
    "swversion": "1.0.1",
    "type": "ZHAFire",
    "uniqueid": "b4:e3:f9:ff:fe:37:9c:d9-01-ef00"
}

DDF:

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE200_aycxwiau",
  "modelid": "TS0601",
  "vendor": "WOOX",
  "product": "Smart Smoke Alarm R7049",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_FIRE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0xef00"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0051",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0xEF00"
        ]
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "awake": true,
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/errorcode",
          "awake": true,
          "parse": {
            "dpid": 11,
            "eval": "Item.val = String(Attr.val);",
            "fn": "tuya"
          }
        },
        {
          "name": "state/fire",
          "awake": true,
          "parse": {"dpid": 1, "eval": "Item.val = (Attr.val == 0 ? true : false);","fn": "tuya" },
          "default": false
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lowbattery",
          "parse": {"dpid": 14, "eval": "Item.val = (Attr.val == 0 ? true : false);", "fn": "tuya" },
          "default": false
        },
        {
          "name": "state/test",
          "awake": true,
          "parse": {"dpid": 8, "eval": "Item.val = (Attr.val == 0 ? false : true);", "fn": "tuya" },
          "default": false
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0xEF00"
    }
  ]
}

Ha yep, to have the support using DDF instead of legacy code.
I have check all already present device that look like this one (using the tuya cluster), but they are different, so realy need a new DDF (and Woox have it’s own folder for device)

Are you sure you need the “tuya bind” (at the end), most of tuya device have it natively.
Already present DDF can have problem too ^^ (I have see some “possible useless” code inside)

Hi Smanar, no I am not sure, should I remove it? Here is the PR, although somehow also some previous commits are included and I don’t know how to fix it :roll_eyes:. Note that I changed the lowbattery logic (true if DPID 14 == 0) based on some experiments and measurements. I always wondered why these devices permanently needed new batteries :grin:.

BTW, one thing I find quite annoying is that in the DDF editor in the GUI, DDFs are not reloaded properly if modifications via an external editor are done. I have to restart deconz every time (hassio add-on).

Make the test, there is another DDF with it, but I m sure at 99% it’s useless.

I always wondered why these devices permanently needed new batteries

Can be deconz fault sometime, or protection from tuya on some others, and ofc bad code in DDF ^^

BTW, one thing I find quite annoying is that in the DDF editor in the GUI, DDFs are not reloaded properly if modifications via an external editor are done. I have to restart deconz every time (hassio add-on).

Yeah, for me the editor is not usable for sensors, too much problem, less problem using a text editor, but no other choice than restarting deconz.

although somehow also some previous commits are included and I don’t know how to fix it

Yep, have just see that, you mean about the “bosch device” ?
I think it will be easier to restart the PR, you are just using your browser to do it ? So need to play with branch, you need to return to the master branch before creating a new one, else depending on your manipulation you can make a new branch based on the actual one.

Edit:
There is problem, you are not synchronised with the offical master

This branch is 2 commits ahead, 1 commit behind dresden-elektronik:master.

And this is not easier to correct ( commit behind are not a problem, but for ahead it’s another story), on my side have used command line to repair that, but perhaps this can help you Restauration d’une demande de tirage (pull request) - Documentation GitHub

The problem is probably from thoses PR, you have made in in the master branch, so now you have a new one (your master don’t follow the official one)

Edit:
IMPORTANT.

Now it’s too late, you have a PR with them DDF for Bosch Smoke Alarm II (#9) by Finne75 · Pull Request #7354 · dresden-elektronik/deconz-rest-plugin · GitHub
If you edit something you will losse your PR.

For me it’s better to wait for Manup merge your first PR and after make a new one for next devices.

This PR is already approuved and in the Milestone, so will be merged soon.