dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.88k stars 483 forks source link

Tuya Photoelectric Smoke Detector _TZE200_m9skfctm #6734

Closed BabaIsYou closed 1 year ago

BabaIsYou commented 1 year ago

Device

Screenshots

image

Basic

image

Groups

image image image

Scenes

image

Information found here and here

BabaIsYou commented 1 year ago

Testing following DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZE200_m9skfctm",
  "modelid": "TS0601",
  "vendor": "Tuya",
  "product": "Photoelectric Smoke sensor",
  "sleeper": true,
  "status": "Silver",
  "subdevices": [
    {
      "type": "$TYPE_FIRE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0xef00"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "parse": {"fn": "zcl", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl", "ep": 1, "cl": "0x0000", "at": "0x0001"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "awake": true,
          "refresh.interval": 3600,
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 15,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 0
        },
        {
          "name": "config/enrolled",
          "public": false
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/errorcode",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 11,
            "eval": "Item.val = String(Attr.val);",
            "fn": "tuya"
          },
          "default": "0"
        },
        {
          "name": "state/fire",
          "awake": true,
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 1,
            "eval": "Item.val = (Attr.val == 1);",
            "fn": "tuya"
          },
          "default": false
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/test",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 101,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 0
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0xEF00"
    }
  ]
}
BabaIsYou commented 1 year ago

Will be able to add another attribute regarding smoke ppm when PR #6673 will be merged

    {
      "name": "state/airqualityco2",
      "awake": true,
      "read": {
        "fn": "none"
      },
      "parse": {
        "dpid": 2,
        "eval": "Item.val = Attr.val ;",
        "fn": "tuya"
      },
      "default": 0
    },
Bernhard-Bodensee commented 1 year ago

I am new to this, I dont know if I can add a comment to closed issues. But anyway I try:

Behavior is not as expected: Included DDF in devices (local), restarted deconz, phoscon and homebridge. After pairing with phoscon "add sensor", one alarm occured and remains, alarm is visible in Homekit and eve Homebridge brings warning when restarted. Consecutive Test alarms have no effect. Battery reading seems ok, tried full battery - 95%, tried 7,22V battery - 10% and warning (beep) of device - so the device is visible

I tried 2 identical sensors, same bevior

Here is some more Info, I hope that helps:

`Homebridge warning at restart:

[14.2.2023, 11:00:00] [Hue] Phoscon-GW: /sensors/20: warning: unknown ZHAFire sensor {"config":{"battery":100,"on":true,"pending":[],"reachable":true},"etag":"4e906bbc13b13bd9446cadbc266ebe31","lastannounced":null,"lastseen":"2023-02-14T09:59Z","manufacturername":"_TZE200_m9skfctm","modelid":"TS0601","name":"Fire 20","state":{"errorcode":"false","fire":true,"lastupdated":"2023-02-14T09:52:51.464","test":false},"type":"ZHAFire","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"}`

API-Info:
                    {
    "config": {
        "battery": 100,
        "on": true,
        "pending": [],
        "reachable": true
    },
    "etag": "5c83c615aaf499631e49ba82e9da2d3a",
    "lastannounced": null,
    "lastseen": "2023-02-14T10:28Z",
    "manufacturername": "_TZE200_m9skfctm",
    "modelid": "TS0601",
    "name": "Fire 20",
    "state": {
        "errorcode": "false",
        "fire": true,
        "lastupdated": "2023-02-14T10:22:43.769",
        "test": false
    },
    "type": "ZHAFire",
    "uniqueid": "a4:c1:38:3f:87:e4:8b:ae-01-ef00"
Events:
    "11:31:56:284": {
        "attr": {
            "id": "20",
            "lastannounced": null,
            "lastseen": "2023-02-14T10:31Z",
            "manufacturername": "_TZE200_m9skfctm",
            "modelid": "TS0601",
            "name": "Fire 20",
            "swversion": null,
            "type": "ZHAFire",
            "uniqueid": "a4:c1:38:3f:87:e4:8b:ae-01-ef00"
        },
        "e": "changed",
        "id": "20",
        "r": "sensors",
        "t": "event",
        "uniqueid": "a4:c1:38:3f:87:e4:8b:ae-01-ef00"
    }
}
debug view:               

11:22:32:594 Poll APS request to 0xEC1BBDFFFEAED1F8 cluster: 0x0006 dropped, values are fresh enough
11:22:32:763 APS-DATA.indication from child 0x7217
11:22:32:880 APS-DATA.indication from child 0xA8F6
11:22:33:069 APS-DATA.indication from child 0x7217
11:22:33:102 APS-DATA.indication from child 0xA8F6
11:22:33:108 TY_DATA_REPORT: seq 201, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:33:109 TY_DATA_REPORT: seq 201, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:33:110 TY_DATA_REPORT: seq 201, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:33:111 TY_DATA_REPORT: seq 201, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:33:113 Websocket 192.168.178.70:50658 send message: {"config":{"battery":100,"on":true,"pending":[],"reachable":true},"e":"changed","id":"20","r":"sensors","t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:33:114 Websocket 192.168.178.47:51354 send message: {"config":{"battery":100,"on":true,"pending":[],"reachable":true},"e":"changed","id":"20","r":"sensors","t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:33:196 APS-DATA.indication from child 0xA8F6
11:22:33:250 APS-DATA.indication from child 0xA8F6
11:22:33:255 TY_DATA_REPORT: seq 202, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:33:257 TY_DATA_REPORT: seq 202, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:33:257 TY_DATA_REPORT: seq 202, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:33:260 TY_DATA_REPORT: seq 202, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:33:262 Websocket 192.168.178.70:50658 send message: {"e":"changed","id":"20","r":"sensors","state":{"errorcode":"false","fire":true,"lastupdated":"2023-02-14T10:22:33.260","test":true},"t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:33:264 Websocket 192.168.178.47:51354 send message: {"e":"changed","id":"20","r":"sensors","state":{"errorcode":"false","fire":true,"lastupdated":"2023-02-14T10:22:33.260","test":true},"t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:33:384 APS-DATA.indication from child 0x7217
11:22:33:445 APS-DATA.indication from child 0xA8F6
11:22:33:544 poll node 60:a4:23:ff:fe:11:83:50-0b
11:22:33:545 Poll light node Wohnzimmer-Schalter
11:22:33:592 Poll APS request to 0x60A423FFFE118350 cluster: 0x0006 dropped, values are fresh enough
11:22:33:690 APS-DATA.indication from child 0x7217
11:22:34:009 APS-DATA.indication from child 0x7217
11:22:34:325 APS-DATA.indication from child 0x7217
11:22:34:543 poll node ec:1b:bd:ff:fe:ae:d1:f8-0b
11:22:34:544 Poll light node Küche-Schalter
11:22:34:590 Poll APS request to 0xEC1BBDFFFEAED1F8 cluster: 0x0006 dropped, values are fresh enough
11:22:34:644 APS-DATA.indication from child 0x7217
11:22:34:952 APS-DATA.indication from child 0x7217
11:22:34:967 APS-DATA.indication from child 0xA8F6
11:22:34:972 TY_DATA_REPORT: seq 203, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:34:974 TY_DATA_REPORT: seq 203, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:34:975 TY_DATA_REPORT: seq 203, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:34:975 TY_DATA_REPORT: seq 203, dpid: 0x0F, type: 0x02, length: 4, val: 100
11:22:34:977 Websocket 192.168.178.70:50658 send message: {"config":{"battery":100,"on":true,"pending":[],"reachable":true},"e":"changed","id":"20","r":"sensors","t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:34:979 Websocket 192.168.178.47:51354 send message: {"config":{"battery":100,"on":true,"pending":[],"reachable":true},"e":"changed","id":"20","r":"sensors","t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:35:100 APS-DATA.indication from child 0xA8F6
11:22:35:105 TY_DATA_REPORT: seq 204, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:35:106 TY_DATA_REPORT: seq 204, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:35:107 TY_DATA_REPORT: seq 204, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:35:108 TY_DATA_REPORT: seq 204, dpid: 0x65, type: 0x01, length: 1, val: 1
11:22:35:110 Websocket 192.168.178.70:50658 send message: {"e":"changed","id":"20","r":"sensors","state":{"errorcode":"false","fire":true,"lastupdated":"2023-02-14T10:22:35.108","test":true},"t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:35:111 Websocket 192.168.178.47:51354 send message: {"e":"changed","id":"20","r":"sensors","state":{"errorcode":"false","fire":true,"lastupdated":"2023-02-14T10:22:35.108","test":true},"t":"event","uniqueid":"a4:c1:38:3f:87:e4:8b:ae-01-ef00"} (ret = 2123296776)
11:22:35:206 APS-DATA.indication from child 0xA8F6
11:22:35:263 APS-DATA.indication from child 0x7217
11:22:35:414 APS-DATA.indication from child 0xA8F6
11:22:35:540 poll node 60:a4:23:ff:fe:11:83:50-0b
11:22:35:541 Poll light node Wohnzimmer-Schalter
11:22:35:575 APS-DATA.indication from child 0x7217
11:22:35:589 Poll APS request to 0x60A423FFFE118350 cluster: 0x0006 dropped, values are fresh enough
11:22:35:637 Daylight now: goldenHour1, status: 160, daylight: 1, dark: 0
11:22:35:731 APS-DATA.indication from child 0xA8F6
11:22:35:891 APS-DATA.indication from child 0x7217
11:22:36:044 APS-DATA.indication from child 0xA8F6
11:22:36:204 APS-DATA.indication from child 0x7217
11:22:36:350 APS-DATA.indication from child 0xA8F6
11:22:36:517 APS-DATA.indication from child 0x7217
11:22:36:535 poll node ec:1b:bd:ff:fe:ae:d1:f8-0b
11:22:36:536 Poll light node Küche-Schalter
11:22:36:587 Poll APS request to 0xEC1BBDFFFEAED1F8 cluster: 0x0006 dropped, values are fresh enough
11:22:36:661 APS-DATA.indication from child 0xA8F6
11:22:36:832 APS-DATA.indication from child 0x7217
BabaIsYou commented 1 year ago

Hi. A bit weird because mine is fully functional with that DDF and a test returns an event with test:true.

Do you mean that you have a fire alarm but the device does not make a at noise ? And right after pairing the device without doing anything else ?

I don’t see any version information in your request. Then I suppose that you don’t have the tuya_version.js under your local directory. Can you make a screenshot from DeConz GUI basic cluster to show the version please (may be a new firmware ?)

Bernhard-Bodensee commented 1 year ago

Bildschirmfoto 2023-02-14 um 12 56 47

When I press the butten the device make the beep beep beep... until I press again. Looks normal. I never installed any tuya stuff, how can I check that? The versions of conbee/phoscon and homebridge are the latest. I also tried to remove everything, strange to me: the sensor still exists. Can there be some caching problem, some old stuff is used somewhere? I am using a browser w/o caching and I have cleared the homebridge cache already. But I dont know how to clear caches in deconz or phoscon???

Bernhard-Bodensee commented 1 year ago

My configuration: raspberry 3B mit Linux raspberrypi 5.10.60-v7+ #1449 SMP Wed Aug 25 15:00:01 BST 2021 armv7l GNU/Linux Homebridge [v1.6.0] homebridge-hue v0.13.51 deCONZ_ConBeeII_0x26780700.bin.GCF phoscon/deconz: Bildschirmfoto 2023-02-14 um 15 28 56

BabaIsYou commented 1 year ago

When I press the butten the device make the beep beep beep... until I press again. Looks normal.

Yes that's the test button. Then you should have an event in Phoscon with "test": true. That's normal behavior. What makes me in trouble is the "fire": true that you have in you previous post.

I also tried to remove everything, strange to me: the sensor still exists.

Where is it still present ? In Deconz, Phoscon, Homebridge ? Everywhere ? How did you delete it ?

Bernhard-Bodensee commented 1 year ago

Bildschirmfoto 2023-02-14 um 18 21 37

still the same, when I hit the test button, "test": true. but in every record it shows "fire":true , this is probably the reason for showing the alarm in homekit and eve permanently. I have not found any info how to factory reset the device, when I hit the button for longer it seems to go into pairing mode only.

Regarding "removal" and start all over: This is how I did it: I removed battery from device, deleted the node in deconz, deleted the DDF-File (local), stopped deconz, restarted deconz and homebridge and homekit - then the device was still in all of them with alarm on!

BTW: The device has never been visible in Phoscon but I learned that that is normal for temporary DDFs.

What would be the correct way/sequence of actions to remove the 2 smoke devices currently paired and start all over ?

Any ideas about the warning message in homebridge? "phoscon-GW: /sensors/19: warning: unknown ZHAFire sensor etc..." ?

BabaIsYou commented 1 year ago

"phoscon-GW: /sensors/19: warning: unknown ZHAFire sensor etc..."

Got exactly the same ... I don't really care about Phoscon for this device... I sometimes used it just to have a friendly gui to access some information like json ;-)

It's weird that your device present "fire": true because the default in DDF is false. Then perhaps means that your device seems to present really an alarm and it's may be faulty ?

To delete a device, it's seems you did it like it could be done. Perhaps you could try to delete the device before remove battery and restart deconz bfore putting the battery back and repairing the device.

It's strange that the device stay after delete. You say that you have two of them, is it the previous "deleted" one and the second the device after rejoining ? Do they have different sensor id ? And how could Deconz handle the same uniqueid on two difference sensor ?

Could you provide for both what you called API-Info previously ?

Bernhard-Bodensee commented 1 year ago

Bildschirmfoto 2023-02-14 um 22 59 46 Bildschirmfoto 2023-02-14 um 23 01 39 Bildschirmfoto 2023-02-14 um 23 01 58

The 2 devices are different, got different Mac/NWK, there is no mix, deconz and all other components process that correctly. I paired fire-20 this morning for the first time just to see if it behaves the same as fire-19. I would assume that it is unlikely that 2 devices got the same fault, but still possible. I will try more things tomorrow - I would hate my neighbors calling fire brigade caused by my test alarms...

BabaIsYou commented 1 year ago

Ok I understand. And you’re right, chances to get two faulty devices at the same time … hmmm 🤔

Bernhard-Bodensee commented 1 year ago

Bildschirmfoto 2023-02-15 um 17 55 53

I could not reproduce that the device is still visible somewhere after removal in deconz. Maybe I fell into a trap with data from cache. Every removal and repairing of the same device results in a new sequence number fire-19, fire-20, fire 21 etc- with the same uniqueid - that looks normal. However, Result in API-Info/events is always the same: fire = true If I hit the test button that is shown inaddition to fire = true.

I played around a bit in the DDF setting the default to different values like "0" and "false" or empty etc - no change. I am lost now, I hope you got some idea on how to proceed.

BabaIsYou commented 1 year ago

Every removal and repairing of the same device results in a new sequence number fire-19, fire-20, fire 21 etc- with the same uniqueid - that looks normal.

Yes, it is !

I hope you got some idea on how to proceed.

Not he idea of the century for sure : did you try to click in basic cluster on exec button to reset to factory default ? In the mean time could you get some log with just INFO and DDF checked ? it's sufficient to get DDF evals and Tuya request/response ?

Bernhard-Bodensee commented 1 year ago

I hit the exec button. But nothing really happened. I would expect that the device would require repairing after factory reset but it just continued working and spreading "fire: true". How do I get the log info you requested :"get some log with just INFO and DDF checked ? it's sufficient to get DDF evals and Tuya request/response ?"

BTW: swversion is null or that line is missing in event records.

   "22:51:39:526": {
        "attr": {
            "id": "22",
            "lastannounced": "2023-02-15T21:43:28Z",
            "lastseen": "2023-02-15T21:51Z",
            "manufacturername": "_TZE200_m9skfctm",
            "modelid": "TS0601",
            "name": "Fire 22",
            "swversion": null,
            "type": "ZHAFire",
            "uniqueid": "a4:c1:38:b3:eb:2a:c7:e9-01-ef00"
        },
        "e": "changed",
        "id": "22",
        "r": "sensors",
        "t": "event",
        "uniqueid": "a4:c1:38:b3:eb:2a:c7:e9-01-ef00"
    }
}

In the DDF it shows:

name": "attr/swversion",
          "parse": {"fn": "zcl", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl", "ep": 1, "cl": "0x0000", "at": "0x0001"}

I don´t see a script file "tuya_swversion.js" in my Home dir. Could that be a problem?

BabaIsYou commented 1 year ago

Could that be a problem?

It shouldn't. You can make a copy of /usr/share/deCONZ/devices/tuya/tuya_swversion.jsto the same folder of your DDF if you want to be sure, but IFIAK it doesn't really matter.

How do I get the log info you requested :"get some log with just INFO and DDF checked ? it's sufficient to get DDF evals and Tuya request/response ?"

In fact you already gave it previously here. Can you propuce it again with just INFO and DDF checked ? image I want to catch the update of state/fire thru dpid: 0x01

BabaIsYou commented 1 year ago

To be very honest, I based my DDF on other plateform information (ie : https://github.com/Koenkk/zigbee-herdsman-converters/commit/1ca479c45e804eb6827cc2bac912ec0091be71d2) but I have some doubt about what tuya.valueConverter.true0ElseFalse function does. If it returns a boolean value that is true if "v" is equal to zero, and false otherwise, then could it be that it is mine that is faulty and that the default correct value would be 1 instead of 0 ?

In that case the eval part of the DDF should be : "eval": "Item.val = (Attr.val == 0);"

Bernhard-Bodensee commented 1 year ago

Thanks a lot for your great support and fast replies - and the patience with me...

Step by step - I hope I am not presenting this in a too confusing way. My simple observation:

  1. Tuya version still wrong even after copying tuya_swversion.js into $HOME and .local...device where the DDF resides. But that is not the main problem. Lets forget about that.

  2. This is the debug view with "eval": "Item.val = (Attr.val == 1);",like in the master DDF-file, after insertion of battery (shows the dpid 0x01 =1 for true)

    18:58:28:184 Bind response success for 0x60a423fffe118350 ep: 0x0B cluster: 0x0006
    18:58:28:239 ZCL configure reporting rsp seq: 64 0x60A423FFFE118350 for ep: 0x0B cluster: 0x0006 attr: 0x0000 status: 0x00
    18:58:47:491 DeviceAnnce of SensorNode: 0xA4C138B3EB2AC7E9 [1]
    18:58:49:179 Bind response success for 0x60a423fffe118350 ep: 0x0B cluster: 0x0006
    18:58:49:180 skip configure report for cluster: 0x0006 attr: 0x0000 of node 0x60A423FFFE118350 (seems to be active)
    18:58:52:142 TY_DATA_REPORT: seq 93, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:58:52:143 TY_DATA_REPORT: seq 93, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:58:52:143 TY_DATA_REPORT: seq 93, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:58:52:144 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> false
    18:58:52:145 TY_DATA_REPORT: seq 93, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:58:52:286 TY_DATA_REPORT: seq 94, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:58:52:287 TY_DATA_REPORT: seq 94, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:58:52:288 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/fire expression: Item.val = (Attr.val == 1); --> true
    18:58:52:289 TY_DATA_REPORT: seq 94, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:58:52:290 TY_DATA_REPORT: seq 94, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:58:52:410 TY_DATA_REPORT: seq 95, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:58:52:411 TY_DATA_REPORT: seq 95, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:58:52:411 TY_DATA_REPORT: seq 95, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:58:52:412 TY_DATA_REPORT: seq 95, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:58:52:553 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 84
    18:58:52:553 TY_DATA_REPORT: seq 96, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:58:52:554 TY_DATA_REPORT: seq 96, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:58:52:555 TY_DATA_REPORT: seq 96, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:58:52:555 TY_DATA_REPORT: seq 96, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:58:52:676 TY_DATA_REPORT: seq 97, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:58:52:677 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/errorcode expression: Item.val = String(Attr.val); --> false
    18:58:52:678 TY_DATA_REPORT: seq 97, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:58:52:678 TY_DATA_REPORT: seq 97, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:58:52:679 TY_DATA_REPORT: seq 97, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:58:52:830 ZCL attribute report 0xA4C138B3EB2AC7E9 for cluster: 0x0000, ep: 0x01, frame control: 0x08, mfcode: 0x0000 
    18:58:52:849 ZCL attribute report 0x60A423FFFE118350 for cluster: 0x0006, ep: 0x0B, frame control: 0x18, mfcode: 0x0000 
    18:59:57:707 0x60a423fffe118350 found group 0xFFF0
    18:59:57:708 0x60a423fffe118350 found group 0x0001
    18:59:58:454 0xec1bbdfffeaed1f8 found group 0xFFF0
    18:59:58:455 0xec1bbdfffeaed1f8 found group 0x0001
  3. This is the debug view with "eval": "Item.val = (Attr.val == 0);", as you recommended in your last posting, after insertion of battery (shows the dpid 0x01 =1 for true), same as above. Dont be confused by the system time shown, I tried that first

    
    18:52:36:267 DeviceAnnce of SensorNode: 0xA4C138B3EB2AC7E9 [1]
    18:52:40:944 TY_DATA_REPORT: seq 119, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:52:40:945 TY_DATA_REPORT: seq 119, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:52:40:946 TY_DATA_REPORT: seq 119, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:52:40:947 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> false
    18:52:40:948 TY_DATA_REPORT: seq 119, dpid: 0x65, type: 0x01, length: 1, val: 0
    18:52:41:088 TY_DATA_REPORT: seq 120, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:52:41:090 TY_DATA_REPORT: seq 120, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:52:41:092 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/fire expression: Item.val = (Attr.val == 0); --> false
    18:52:41:093 TY_DATA_REPORT: seq 120, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:52:41:094 TY_DATA_REPORT: seq 120, dpid: 0x01, type: 0x04, length: 1, val: 1
    18:52:41:219 TY_DATA_REPORT: seq 121, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:52:41:220 TY_DATA_REPORT: seq 121, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:52:41:221 TY_DATA_REPORT: seq 121, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:52:41:221 TY_DATA_REPORT: seq 121, dpid: 0x02, type: 0x02, length: 4, val: 0
    18:52:41:349 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 84
    18:52:41:350 TY_DATA_REPORT: seq 122, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:52:41:351 TY_DATA_REPORT: seq 122, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:52:41:353 TY_DATA_REPORT: seq 122, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:52:41:354 TY_DATA_REPORT: seq 122, dpid: 0x0F, type: 0x02, length: 4, val: 84
    18:52:41:583 TY_DATA_REPORT: seq 123, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:52:41:584 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/errorcode expression: Item.val = String(Attr.val); --> false
    18:52:41:584 TY_DATA_REPORT: seq 123, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:52:41:585 TY_DATA_REPORT: seq 123, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:52:41:585 TY_DATA_REPORT: seq 123, dpid: 0x0B, type: 0x01, length: 1, val: 0
    18:52:41:710 ZCL attribute report 0xA4C138B3EB2AC7E9 for cluster: 0x0000, ep: 0x01, frame control: 0x08, mfcode: 0x0000 
    18:53:04:640 GW firmware version is up to date: 0x26780700
    18:53:15:136 00:15:8d:00:07:df:92:f1-01-0405/config/battery expression: const vmin = 2700;
    const vmax = 3000;
    var bat = Attr.val;

if (bat > vmax) { bat = vmax; } else if (bat < vmin) { bat = vmin; }

bat = ((bat - vmin) /(vmax - vmin)) * 100;


4. debug-view when test button is pressed does not show any dpid0x01 items but dpis 0x65 (101) which seems correct

18:33:23:901 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 92 18:33:23:902 TY_DATA_REPORT: seq 98, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:23:903 TY_DATA_REPORT: seq 98, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:23:904 TY_DATA_REPORT: seq 98, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:23:905 TY_DATA_REPORT: seq 98, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:24:137 TY_DATA_REPORT: seq 99, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:24:137 TY_DATA_REPORT: seq 99, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:24:138 TY_DATA_REPORT: seq 99, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:24:139 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> true 18:33:24:140 TY_DATA_REPORT: seq 99, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:25:590 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 92 18:33:25:591 TY_DATA_REPORT: seq 100, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:25:592 TY_DATA_REPORT: seq 100, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:25:593 TY_DATA_REPORT: seq 100, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:25:594 TY_DATA_REPORT: seq 100, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:25:723 TY_DATA_REPORT: seq 101, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:25:725 TY_DATA_REPORT: seq 101, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:25:725 TY_DATA_REPORT: seq 101, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:25:727 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> true 18:33:25:727 TY_DATA_REPORT: seq 101, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:27:145 ZCL attribute report 0xEC1BBDFFFEAED1F8 for cluster: 0x0006, ep: 0x0B, frame control: 0x18, mfcode: 0x0000 18:33:28:478 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 92 18:33:28:479 TY_DATA_REPORT: seq 102, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:28:480 TY_DATA_REPORT: seq 102, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:28:481 TY_DATA_REPORT: seq 102, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:28:482 TY_DATA_REPORT: seq 102, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:28:603 TY_DATA_REPORT: seq 103, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:28:604 TY_DATA_REPORT: seq 103, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:28:605 TY_DATA_REPORT: seq 103, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:28:605 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> true 18:33:28:606 TY_DATA_REPORT: seq 103, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:31:358 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 92 18:33:31:359 TY_DATA_REPORT: seq 104, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:31:359 TY_DATA_REPORT: seq 104, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:31:360 TY_DATA_REPORT: seq 104, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:31:360 TY_DATA_REPORT: seq 104, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:31:489 TY_DATA_REPORT: seq 105, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:31:491 TY_DATA_REPORT: seq 105, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:31:492 TY_DATA_REPORT: seq 105, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:31:494 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> true 18:33:31:496 TY_DATA_REPORT: seq 105, dpid: 0x65, type: 0x01, length: 1, val: 1 18:33:34:242 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/config/battery expression: Item.val = Attr.val; --> 92 18:33:34:243 TY_DATA_REPORT: seq 106, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:34:245 TY_DATA_REPORT: seq 106, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:34:246 TY_DATA_REPORT: seq 106, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:34:248 TY_DATA_REPORT: seq 106, dpid: 0x0F, type: 0x02, length: 4, val: 92 18:33:34:595 TY_DATA_REPORT: seq 107, dpid: 0x65, type: 0x01, length: 1, val: 0 18:33:34:596 TY_DATA_REPORT: seq 107, dpid: 0x65, type: 0x01, length: 1, val: 0 18:33:34:597 TY_DATA_REPORT: seq 107, dpid: 0x65, type: 0x01, length: 1, val: 0 18:33:34:598 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/test expression: Item.val = Attr.val; --> false 18:33:34:599 TY_DATA_REPORT: seq 107, dpid: 0x65, type: 0x01, length: 1, val: 0 18:33:38:451 ZCL attribute report 0x60A423FFFE118350 for cluster: 0x0006, ep: 0x0B, frame control: 0x18, mfcode: 0x0000 18:34:59:640 GW firmware version is up to date: 0x26780700 18:36:28:690 ZCL attribute report 0xEC1BBDFFFEAED1F8 for cluster: 0x0006, ep: 0x0B, frame control: 0x18, mfcode: 0x0000 18:38:41:322 ZCL attribute report 0x60A423FFFE118350 for cluster: 0x0006, ep: 0x0B, frame control: 0x18, mfcode: 0x0000 18:38:59:637 GW firmware version is up to date: 0x26780700 18:39:30:248 ZCL attribute report 0xEC1BBDFFFEAED1F8 for cluster: 0x0006, ep: 0x0B, frame control: 0x18, mfcode: 0x0000

Bernhard-Bodensee commented 1 year ago

I did the above without pairing again - just restarted deconz and inserted the battery into the device. Is that sufficient? From my understanding a DDF change is active when either "Hot reload" is pressed or after restart of deconz. I hate to run into problems of many renumberings and running out of numbers - if that is a real problem?

Bernhard-Bodensee commented 1 year ago

I think I got the solution, in addition to setting value you need to change default to 1 - then it works. I am testing now... found no problem so far.

          "name": "state/fire",
          "awake": true,
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 1,
            "eval": "Item.val = (Attr.val == 0);",
            "fn": "tuya"
          },
          "default": true
        },
BabaIsYou commented 1 year ago

18:52:41:092 a4:c1:38:b3:eb:2a:c7:e9-01-ef00/state/fire expression: Item.val = (Attr.val == 0); --> false 4. debug-view when test button is pressed does not show any dpid0x01 items but dpis 0x65 (101) which seems correct

That's clearly what we were waiting for these two attributes ! ;-)

I did the above without pairing again - just restarted deconz and inserted the battery into the device. Is that sufficient? From my understanding a DDF change is active when either "Hot reload" is pressed or after restart of deconz.

From my experience a hot reload only works after modified the DDF using DDF editor and saved the file. And sometimes you loose the swversion definition doing that way. Then modifying DDF using text editor and restarting DeCONZ is the best way at this time to be sure that the DDF is used at startup. No need to repair if you don't change subdevice or endpoints inside the DDF.

you need to change default to 1

Are you sure ? Doing that means that if value couldn't be parsed then fire will be true and then means that there is a fire condition !?

Could you try this other formula and keep "default": false ? "eval": "Item.val = (Attr.val == 0 ? true : false);",

Bernhard-Bodensee commented 1 year ago

I think we entered our comments at the same time. Problem solved as I mentioned above with Attr.val == 0 and default": true

Strange, normal people would think 1 if fire - but in fact for tuya 0 seems to be fie alarm. Regardsless of my understanding: I tested that solution with the 2 devices I got. When I hit test, alarm goes on and is displayed on all Home Apps as Notification (iPhone, iPad, Mac). Homebridge still has that warning as mentioned but that can be disregarded. Phoscon shows the correct values in API-Info and alerts - when test is pressed it shows both, fire and test are true. When the device is ling it shows both as false.

Thanks a lot for your great support. Greetings from the Lake of Constance

BabaIsYou commented 1 year ago

in fact for tuya 0 seems to be fie alarm.

Yes for this kind of device it seems to be that way internaly, but for HA systems, fire race is when fire attribute is true. That's why we have to invert he logic and made the attribute fire to be true when tuya send 0, and false otherwise. That's why I think that default to true seems very weird.

Bernhard-Bodensee commented 1 year ago

I will try your settings tomorrow and get back to you.

Could you try this other formula and keep "default": false ?
"eval": "Item.val = (Attr.val == 0 ? true : false);",
Bernhard-Bodensee commented 1 year ago

works. No problems found. Tested essential funktions (idle, alarm, battery change), everything fine.

Looks probably better than default =true If I understand your fix it looks like a workaround for the stupid device reaction ? if Attr.val is false set to true! Let me know if you need any more analysis data.

BabaIsYou commented 1 year ago

Many thx 🙏 PR updated