Heiman HS2WD-E siren: state.alert always remains at "none"

I’m clearly not familiar with alarm management in Zigbee environment. I used DDF proposed by @Swoop related to issue https://forum.phoscon.de/t/heiman-warningdevice-ef-3-0-siren-no-battery-and-tampered-status/2346 opened by @monpelaud. I just added ZHABattery as a suggestion because the specific cluster 0001 has attributes for that purpose.

Well, correcting it in DDF lead me to another issue. config/battery is set to 0 where state/battery was with a right value

{
  "config": {
    "battery": 0,
    "on": true,
    "pending": [],
    "reachable": true
  },
  "ep": 1,
  "etag": "090140dfffed16e5e1129a711c762381",
  "lastannounced": null,
  "lastseen": "2022-10-07T17:07Z",
  "manufacturername": "HEIMAN",
  "modelid": "WarningDevice-EF-3.0",
  "name": "Sirene bureau alarme",
  "state": {
    "alarm": null,
    "lastupdated": "2022-10-06T21:35:13.264",
    "lowbattery": null
  },
  "type": "ZHAAlarm",
  "uniqueid": "84:71:27:ff:fe:fe:ab:08-01-0500",
  "id": "36",
  "deviceclass": "sensors"
}
{
  "config": {
    "battery": 0,
    "on": true,
    "pending": [],
    "reachable": true
  },
  "ep": 1,
  "etag": "3f0218f94f714dae82c54182ee0143f8",
  "lastannounced": null,
  "lastseen": "2022-10-07T17:13Z",
  "manufacturername": "HEIMAN",
  "modelid": "WarningDevice-EF-3.0",
  "name": "Sirene bureau alarme",
  "state": {
    "alarm": null,
    "battery": 87,
    "lastupdated": "2022-10-07T17:13:21.354",
    "lowbattery": null
  },
  "type": "ZHAAlarm",
  "uniqueid": "84:71:27:ff:fe:fe:ab:08-01-0500",
  "id": "36",
  "deviceclass": "sensors"
}

Try with removing state/battery and using

        {
          "name": "config/battery",
          "refresh.interval": 3600,
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Attr.val / 2",
            "fn": "zcl"
          }
        },

To force it.

I don’t understand why should I configure the read-only attribute for this device to config/battery as the state/battery also exists and works ?

State/battery is reserved to the sensor ZHABattery.
Light device don’t have “config” but don’t have battery, so we use the ZHABattery for battery covering for exemple.
And sensor use config/battery, never state/battery.

That’s what I initialy did that did not work.
But after changing config/battery by state/battery in the DDF make the item apearing with a value (87 in my example above).

Here is the DDF :

{
  "schema": "devcap1.schema.json",
  "manufacturername": [
    "Heiman",
    "HEIMAN"
  ],
  "modelid": [
    "WarningDevice",
    "WarningDevice-EF-3.0"
  ],
  "vendor": "Heiman",
  "product": "Smart siren HS2WD-E",
  "sleeper": false,
  "status": "Silver",
  "path": "/devices/HS2WD-E.json",
  "subdevices": [
    {
      "type": "$TYPE_WARNING_DEVICE",
      "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/alert",
          "default": "none"
        },
        {
          "name": "state/reachable"
        }
      ]
    },
    {
      "type": "ZHAAlarm",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0500"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0403",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0x0001",
          "0x0500"
        ]
      },
      "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/battery",
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Attr.val / 2",
            "fn": "zcl"
          },
          "default": 0
        },
        {
          "name": "config/enrolled",
          "public": false
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/alarm"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lowbattery"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0021",
          "dt": "0x20",
          "min": 120,
          "max": 3600,
          "change": "0x00000001"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0500"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0502",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x21",
          "min": 30,
          "max": 120
        }
      ]
    }
  ]
}

and the resulting json :

{
  "config": {
    "battery": 0,
    "on": true,
    "pending": [],
    "reachable": true
  },
  "ep": 1,
  "etag": "712a292a7d2d5d82abd71445319ed49c",
  "lastannounced": null,
  "lastseen": "2022-10-11T16:23Z",
  "manufacturername": "HEIMAN",
  "modelid": "WarningDevice-EF-3.0",
  "name": "Sirene bureau alarme",
  "state": {
    "alarm": null,
    "lastupdated": "2022-10-11T14:46:02.369",
    "lowbattery": null
  },
  "type": "ZHAAlarm",
  "uniqueid": "84:71:27:ff:fe:fe:ab:08-01-0500",
  "id": "36",
  "deviceclass": "sensors"
}

That’s a bit weird because in the log I got the retreiving of the data :

12:42:02:934 50:0b:91:40:00:02:ca:1c-01-0201/config/heatsetpoint expression: Item.val = Attr.val; --> 1800
**12:42:03:434 84:71:27:ff:fe:fe:ab:08-01-0500/config/battery expression: Item.val = Attr.val / 2 --> 86.5**
12:42:04:069 50:0b:91:40:00:02:ca:1c-01-0201/config/heatsetpoint expression: Item.val = Attr.val; --> 1800
**12:42:05:779 84:71:27:ff:fe:fe:ab:08-01-0500/config/battery expression: Item.val = Attr.val / 2 --> 86.5**

Seriously, every day a new problem …
What is your deconz version ?

Just for the fun, can you try using “/ 3” in the DDF instead of using " / 2" to check if the DDF is realy used.
Or removing the “defaut” : 0

No line that set the “0” value just after in logs ?

I guess there is no trouble with the “defaut” : 0 because the value has been updated when the percentage rise from 86.5 to 87.

Tried to put the calculation with /3 instead of /2 and the DDF is used

15:48:40:752 84:71:27:ff:fe:fe:ab:08-01-0500/config/battery expression: Item.val = Attr.val / 3 --> 57.666666666666664

But no value transmitted in the json … it keeps 87

{
  "config": {
    "battery": 87,
    "on": true,
    "pending": [],
    "reachable": true
  },
  "ep": 1,
  "etag": "98b96a8001ec29fd4d389cea0791f31e",
  "lastannounced": null,
  "lastseen": "2022-10-11T19:23Z",
  "manufacturername": "HEIMAN",
  "modelid": "WarningDevice-EF-3.0",
  "name": "Sirene bureau alarme",
  "state": {
    "alarm": null,
    "lastupdated": "2022-10-11T14:46:02.369",
    "lowbattery": null
  },
  "type": "ZHAAlarm",
  "uniqueid": "84:71:27:ff:fe:fe:ab:08-01-0500",
  "id": "36",
  "deviceclass": "sensors"
}

Could it be a rounded issue ? Should this value be an integer to be used ?

I will link this post to dev channel to have tips.
Seriously I have no idea what happen

Can you show the complete DDF ?

Of course, here it is

{
  "schema": "devcap1.schema.json",
  "manufacturername": [
    "Heiman",
    "HEIMAN"
  ],
  "modelid": [
    "WarningDevice",
    "WarningDevice-EF-3.0"
  ],
  "vendor": "Heiman",
  "product": "Smart siren HS2WD-E",
  "sleeper": false,
  "status": "Silver",
  "path": "/devices/HS2WD-E.json",
  "subdevices": [
    {
      "type": "$TYPE_WARNING_DEVICE",
      "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/alert",
          "default": "none"
        },
        {
          "name": "state/reachable"
        }
      ]
    },
    {
      "type": "ZHAAlarm",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0500"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0403",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0x0001",
          "0x0500"
        ]
      },
      "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/battery",
          "refresh.interval": 120,
          "read": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "fn": "zcl"
          },
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Attr.val / 2",
            "fn": "zcl"
          },
          "default": 0
        },
        {
          "name": "config/enrolled",
          "public": false
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/alarm"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lowbattery"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0021",
          "dt": "0x20",
          "min": 120,
          "max": 3600,
          "change": "0x00000001"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0500"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0502",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x21",
          "min": 30,
          "max": 120
        }
      ]
    }
  ]
}

Tried to replace the calculated value by Item.val = Math.round(Attr.val / 3); in the DDF and it works instantaneously !

{
    "config": {
        "battery": 58,
        "on": true,
        "pending": [],
        "reachable": true
    },
    "ep": 1,
    "etag": "bb0d59a153d90eb768d91286dfc176c9",
    "lastannounced": null,
    "lastseen": "2022-10-12T16:46Z",
    "manufacturername": "HEIMAN",
    "modelid": "WarningDevice-EF-3.0",
    "name": "Sirene bureau alarme",
    "state": {
        "alarm": null,
        "lastupdated": "2022-10-11T14:46:02.369",
        "lowbattery": null
    },
    "type": "ZHAAlarm",
    "uniqueid": "84:71:27:ff:fe:fe:ab:08-01-0500"
}

Then really think that a integer is attended here.

Then replaced it by Item.val = Math.round(Attr.val / 2); for the moment.

And BTW Swoops have see another strange problem, look at your device json, you have an entry “deviceclass”

  "id": "36",
  "deviceclass": "sensors"
}

It may be came from the DDF that @Swoop gave in the other thread : https://forum.phoscon.de/t/heiman-warningdevice-ef-3-0-siren-no-battery-and-tampered-status/2346/5

{
“type”: “ZHAAlarm”,
“restapi”: “/sensors”,
“uuid”: [
“$address.ext”,
“0x01”,
“0x0500

And it’s the same in PR #6397