dresden-elektronik / deconz-rest-plugin

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

Human Presence Detector - ZY-M100-S #6517

Closed McKenzer closed 1 year ago

McKenzer commented 2 years ago

Device

bought here

Screenshots

Basic

image image

Groups

image image

Scenes

image

Tuya specific Cluster

image

On/Off

image

Working Device Occupancy Sensor from Aqara Basic

image image

BabaIsYou commented 1 year ago

Perhaps a conversion issue, will wait for results from @manosioa because mine are still strange.

manosioa commented 1 year ago

Here is my actual DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": [
    "_TZE200_ztc6ggyl",
    "_TZE204_ztc6ggyl"
  ],
  "modelid": [
    "TS0601",
    "TS0601"
  ],
  "product": "Human Presence Detector - ZY-M100",
  "sleeper": true,
  "status": "Silver",
  "path": "/devices/ZY-M100_human_breathing_presence.json",
  "subdevices": [
    {
      "type": "$TYPE_LIGHT_LEVEL_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0400"
      ],
      "items": [
        {
          "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/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lux",
          "description": "The current light intensity in Lux (max is 2000)",
          "refresh.interval": 5,
          "read": {
            "fn": "tuya"
          },
          "parse": {
            "dpid": 104,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 0
        }
      ]
    },
    {
      "type": "$TYPE_PRESENCE_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",
          "refresh.interval": 83999,
          "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/delay",
          "description": "Detection delay : target confirmation delay time in 10th of second (from 0 to 100). Default 0.1s",
          "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 101,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 101,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 1
        },
        {
          "name": "config/duration",
          "description": "Fading time : target disapperance delay time in second (from 0 to 15000). Default 90s",
          "read": {
            "fn": "tuya"
          },
          "write": {
            "dpid": 102,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 102,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 90
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "config/sensitivity",
          "description": "Radar sensitivity (from 1 to 9). Default 7",
          "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 2,
            "dt": "0x2b",
            "eval": "10*Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 2,
            "eval": "Item.val = Attr.val/10;",
            "fn": "tuya"
          },
          "default": 7
        },
        {
          "name": "state/angle",
          "description": "Distance from detected target in cm (from 0 to 1000).",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 9,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 0
        },
        {
          "name": "state/errorcode",
          "description": "Self check result code. \n0 = checking, 1 = check_success, 2 = check_failure, 3 = others, 4 = comm_fault, 5 = radar_fault",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 6,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": "1"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/presence",
          "refresh.interval": 5,
          "read": {
            "fn": "tuya"
          },
          "parse": {
            "dpid": 1,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": false
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0xEF00"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0006"
    }
  ]
}

Ok, I used the quoted DDF.

I was hoping you could tell me what you need and where I can find it. I'm a fast learner (in 24h I made it work and learned all about HA's docker containers, SSH shell access, what DDF is, and how to make a custom one and load it on a device.) 😄

I've deleted and repaired the sensor. Now the "Smart Plug" has been deleted as well. I've added a second sensor in the living room. HA is reporting only "Delay" and "Duration". Distance, sensitivity, and light are not reported. If I stand very still the sensor cannot detect me. I guess that has to do with sensitivity.

Screenshot 2022-12-20 at 20 02 20 Screenshot 2022-12-20 at 20 03 12

What is the next step? What do you need me to try?

BabaIsYou commented 1 year ago

Well, can you connect to Phoscon, Help, API information, and then select sensors radio button, and by selecting the sensors in the list, catching the information about those related to your device (may be the two last of the list I presume) . Then you will got something like https://github.com/dresden-elektronik/deconz-rest-plugin/issues/6517#issuecomment-1359352740

image

BabaIsYou commented 1 year ago

If you didn't change values you should have default values for sensitivity, duration and delay in the presence sensor : https://user-images.githubusercontent.com/85300265/205787373-6c18f4dc-f79b-49cf-bc37-2be8b4b170af.png.

And these values must be stable. That's not my case ;-( image image

manosioa commented 1 year ago

Well, can you connect to Phoscon, Help, API information, and then select sensors radio button, and by selecting the sensors in the list, catching the information about those related to your device (may be the two last of the list I presume) . Then you will got something like https://github.com/dresden-elektronik/deconz-rest-plugin/issues/6517#issuecomment-1359352740

image

Great, here are my screenshots (should you need the actual logs I can provide them to you) I did change the delay and duration through HA. But only those 2 as everything else is not populated in HA and I cannot change it.

Screenshot 2022-12-20 at 20 10 20 Screenshot 2022-12-20 at 20 15 29
BabaIsYou commented 1 year ago

By default, sensitivity should be 7. Do you have the same values at each refresh ? If not you got the same issue than mine. What is your DeConz version ?

manosioa commented 1 year ago

Yes, sensitivity is stable at 1 in each and every refresh. I did not change anything regarding the sensitivity (I'm not sure where I can do that). The other sensor has the same sensitivity as well (1).

Screenshot 2022-12-20 at 20 35 21
Smanar commented 1 year ago

The DDF work realy better on his version :( I m sorry @BabaIsYou but manup is back from holiday, hoping for a massive PR merge soon

BabaIsYou commented 1 year ago

Yes, it seems more stable, and it's good news BTW. If PR #6011 could be included in the next batch that would be perfect ... If not I will upgrade anyway and redo the chhanges manually.

@manosioa coukd you please modify the DFF to :

  1. suppress the /10 in parse section of sensitivity item . 1 in place of 7 is may be the cause.
          "parse": {
            "dpid": 2,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
  2. as @smanar told earlier, you can remove in DDF for lux

"refresh.interval": 5,

Then I think that a PR could be made for this device (#6621)

In fact here is the actual DDF I use :

{
  "schema": "devcap1.schema.json",
  "manufacturername": [
    "_TZE200_ztc6ggyl",
    "_TZE204_ztc6ggyl"
  ],
  "modelid": [
    "TS0601",
    "TS0601"
  ],
  "product": "Human Presence Detector - ZY-M100",
  "sleeper": true,
  "status": "Silver",
  "subdevices": [
    {
      "type": "$TYPE_LIGHT_LEVEL_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0400"
      ],
      "items": [
        {
          "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/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lux",
          "description": "The current light intensity in Lux (max is 2000)",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 104,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 0
        }
      ]
    },
    {
      "type": "$TYPE_PRESENCE_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",
          "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/delay",
          "description": "Detection delay : target confirmation delay time in 10th of second (from 0 to 100). Default 0.1s",
          "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 101,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 101,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 1
        },
        {
          "name": "config/duration",
          "description": "Fading time : target disapperance delay time in second (from 0 to 15000). Default 90s",
          "range": [0, 15000],
          "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 102,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 102,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 90
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "config/sensitivity",
          "description": "Radar sensitivity (from 1 to 9). Default 7",
          "range": [1, 9],
          "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 2,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 2,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 7
        },
        {
          "name": "config/sensitivitymax",
          "description": "Far detection sensitivity in cm. From 0 to 1000. Default 1000",
          "range": [0, 1000],
         "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 4,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 4,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          }
        },
        {
          "name": "state/angle",
          "description": "Distance from detected target in cm (from 0 to 1000).",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 9,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 0
        },
        {
          "name": "state/errorcode",
          "description": "Self check result code. \n0 = checking, 1 = check_success, 2 = check_failure, 3 = others, 4 = comm_fault, 5 = radar_fault",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 6,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": 1
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/presence",
          "refresh.interval": 5,
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 1,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          },
          "default": false
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0xEF00"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0006"
    }
  ]
}
manosioa commented 1 year ago

I did use the DDF you provided and that led to sensors not updating presence. I re added them from scratch using the same DDF you provided but still no presence detection. image imageimage

BabaIsYou commented 1 year ago

It seems that you have the FF issue one more time … "uniqueid":"70:ac:08:ff:fe:21:2b:6c-ff-0400" instead of "uniqueid":"70:ac:08:ff:fe:21:2b:6c-01-0400" ;-( That’s certainly why some items are missing (sensitivity, angle, delay) and others are present but doesn’t exist in DDF (lightlevel, tholddark, …)

manosioa commented 1 year ago

What does "ff issue" mean? I understand that the ff appears in the unique id, but how is that a problem? If it is how can I fix it? What is the next step?

BabaIsYou commented 1 year ago

I already had it for this device (and still have it with another one - a thermostat). You have to delete and repair the device.

At this time nobody found where this bug come from. It’s here and there sometimes in different version ;-(

manosioa commented 1 year ago

I did delete and repair both sensors but something strange happens. Even after I delete them from the Phoscon environment and they are deleted in deCONZ environment as well, when I restart deCONZ add on, I can see both sensors in Phoscon environment but not in deCONZ environment.

Screenshot 2022-12-21 at 16 14 42 Screenshot 2022-12-21 at 16 14 56

Everytime I restart both sensors re appear in Phoscon. It's like it doesn't save the changes. Tried also restarting the GW with no luck.

I deleted them once again and re added them not from Phoscon but from deCONZ using the "Hybrid" option enables in "Control" tab, then "Enable permit join" and then when the device appeared in the map, I went into "Edit DDF" and just clicked on "Hot reload". Without restarting deCONZ the device popped up in Phoscon as a presence device, with it's previous name which remembered and it's working just as before. If I keep very still it fails to recognise I'm in the room but if I move a little bit it recognises me.

Here is the API results which are the same as the last time with the last DDF you provided.

Screenshot 2022-12-21 at 16 29 26

Delay, sensitivity and angle are missing again. those functions were displayed in API with the previous DDF) I used.

I then deleted again the sensor and changed the DDF back to the previous version (you can find it here) that worked better and had the missing functions (Delay, sensitivity and angle) from the latest DDF version you suggested to try. I restarted deCONZ and then re-added the sensor with the same steps as I detailed before. It know appears as "Presence 51" device and not "Smart Plug 6" plus in the API info it appears as "Presence 55" and "LightLevel 54" with the functions Delay, sensitivity and angle once again available!

Screenshot 2022-12-21 at 16 47 35

In Phoscon it appears with a new name (it doesn't remember it's last name as before) "LightLevel54".

As you can see the "uniqueid" is once again correct with only one "ff" in it and not two "ff" as with the the latest DDF version you suggested to try. So my guess is that this DDF version you suggested to try last time is not working properly for me.

Does it work to you?

I'm still missing distance, light lx, version etc. functions. I still cannot adjust the sensitivity in HA even though it has been identified in the API.

Screenshot 2022-12-21 at 16 54 00
Smanar commented 1 year ago

And I think the "magic sensor" that can't be deleted are with the endpoint "FF" ?

I have compared both DDF (but IDK why the last one is not working)

          "read": {
            "fn": "tuya"
          },

and for all other

          "read": {
            "fn": "none"
          },

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.

Don't ask me the impact ^^

But they are minor changes, I don't see why the last DDF is not used ....

BTW the detection is working with the old DDF ?

BabaIsYou commented 1 year ago

I lastly changed « 1 » by 1 … my fault… but seems to work like this for me … even if values are strange ;-/

Perhaps a typo …

Smanar commented 1 year ago

IDK, have used a website to check JSON, no error.

Smanar commented 1 year ago

And BTW what is the defaut level setting for DDF ? On my side it's "Gold" This one is "Silver"

deleted them once again and re added them not from Phoscon but from deCONZ using the "Hybrid" option enables in "Control" tab, then "Enable permit join" and then when the device appeared in the map, I went into "Edit DDF" and just clicked on "Hot reload".

Better to use "Basic" to force DDF for test, but probably need to set the level.

manosioa commented 1 year ago

And I think the "magic sensor" that can't be deleted are with the endpoint "FF" ?

exactly. It needed a special treatment in order to get completelly deleted as per my step by step instructions.

BTW the detection is working with the old DDF ?

yes, detection works with the old DDF in my case. It's sensitivity though defaults at "1" so if i sit very still it changes to clear but if i do a move it detects me.

And BTW what is the defaut level setting for DDF ? On my side it's "Gold" This one is "Silver"

I do not know from where it gets it's status (I guess somewhere in the DDF).

Better to use "Basic" to force DDF for test, but probably need to set the level.

Next time I will set it to "Basic".

Now I have to ask as I'm a total newbie :) Are you guys involved in the deCONZ development is some way? Or just users like me who are trying to help themselves and/or others?

Smanar commented 1 year ago

We are like you ^^. But its not the first device we are trying to make working with deconz. @BabaIsYou have already done lot of DDF. He have the device but he can't use the last deconz version because he have an old special version compiled by himself, waiting for a PR was merged.

I do not know from where it gets it's status (I guess somewhere in the DDF).

Yep, the status in the DDF is "Silver", but the setting you have in deconz in the control/basic have an impact too.

manosioa commented 1 year ago

Awesome! It's the first time I'm going that deep in deCONZ as everything up till now was pretty plug n play for me.

It's certainly fun!

Is there anything that I can try while we wait for PR?

BabaIsYou commented 1 year ago

It's certainly fun!

Welcome on board !! ;-)

BabaIsYou commented 1 year ago

Is there anything that I can try while we wait for PR?

Why not trying to modify some item like sensitivity or other /config just to see if and how it works ;-)

manosioa commented 1 year ago

Of course! I made some changes to the last DDF that was not working before. But I feel I'm blind. I mean, I don't have something to compare it with.

Maybe if we can find the DDF of a working presence sensor, then we could compare and try some of its properties on our DDF.

I do not know how you work and develop the DDF so I'm just guessing and throwing ideas at the table 😄

BabaIsYou commented 1 year ago

Just getting back to working DDF and then try to modify values of attributes like sensitivity (passing from default 7 to maximum 9 or other value) just to see if device is reacting accordingly.

No need to modify DDF once it is loaded, but trying to adjust the values of /config items (don’t know how to do this using HA but can be done using curl)

manosioa commented 1 year ago

I don't know any other way to change it's settings other than straight into DDF and HA. In HA i only have these 2 functions that I can mess with. Nothing else is being populated.

Screenshot 2022-12-22 at 10 43 29
Smanar commented 1 year ago

It's possible too using a REST plugin in your browser, but less friendly https://dresden-elektronik.github.io/deconz-rest-doc/getting_started/

I m seing "Delay" is modifiable in HA, have you tried it ? (need value > 10)

mprajsler commented 1 year ago

Hello guys, another user here with this sensor. After several tries (adding, removing, restarting...) I was able to get rid of "smart plug" in the /lights and just got light and presence under /sensors in the API. Used unmodified DDF from here: https://raw.githubusercontent.com/BabaIsYou/deconz-rest-plugin/17d6e2446b64e0c9fff0684fbf038153f3423387/devices/tuya/ZY-M100_human_breathing_presence.json which I download via wget into HA deCONZ plugin folder.

I am missing "lux" sensor in hassio and do not know what else should I do... here are some screens.

image image image

tried to change these settings image and they change in the API and seems to change the behaviour of the sensor image

HA deCONZ plugin log is flooded with "TY_DATA_REPORT" lines like i.e.: 13:07:46:268 TY_DATA_REPORT: seq 91, dpid: 0x02, type: 0x02, length: 4, val: 7 13:07:46:013 TY_DATA_REPORT: seq 89, dpid: 0x01, type: 0x04, length: 1, val: 0 13:07:46:141 TY_DATA_REPORT: seq 90, dpid: 0x04, type: 0x02, length: 4, val: 600 13:07:46:411 TY_DATA_REPORT: seq 92, dpid: 0x03, type: 0x02, length: 4, val: 0 Not sure if that is OK or not...

Let me know what should I report etc.

BR, M.

BabaIsYou commented 1 year ago

That’s great news because values seems to be in the ranges for all of them.

I read on another thread elsewhere that this device tend to flood a lot … don’t know a way to regulate it …

Message ID: @.***>

Smanar commented 1 year ago

Strange you can't see it in HA if you can see it in the API. Perhaps a synchronisation issue (for exemple if the device was finalized after it was included in HA), if I m right there is a way to re-synchronize device. Perhaps HA need state/lightlevel too ?

Not sure if that is OK or not...

Yeah don't worry it s device return

Dpid 2 is the sensitivty here 7 dpid 1 is the presence here not dpid 4 is maximum range (not used by deconz) dpid 3 is minimum range (not used)

mprajsler commented 1 year ago

Hi, thanks both for response. deCONZ HA plugin got "deconz.device_refresh" service and "deconz.remove_orphaned_entries" and I tried both. I also restarted HA and the plugin itself.

Regarding /lightlevel? this can be truth as all other light sensors I got visible in HA from deCONZ got it i.e. like this aqara sensor: image

but why the light "lux" is detected in API and not visible even in Phoscon? (renamed the sensor to "Presence sensor") image

One thing to note is that DDF got default duration as "90" but once paired I got it as "600" but I changed it via HA...

Smanar commented 1 year ago

One thing to note is that DDF got default duration as "90" but once paired I got it as "600" but I changed it via HA...

Ha yes, lol, nice catch, the DDF set 90 as defaut value, but the device have 600, so when it make the first report it overwrite the defaut value. Good to know if the defaut value definied in DDF is usd only on device creation or at all deconz restart.

Can try to add on DDF

        {
          "name": "state/lightlevel",
          "default": 12345
        },

Then use "hot reload" in the editor or restart deconz, no need to re-include the device. Will be fake value, but like that we can make a test.

mprajsler commented 1 year ago

Tried just that in DDF, saved the file and restarted deconz this is result

image

image

image

restarted HA and here it is

image

Smanar commented 1 year ago

Ok so It seem it's not mandatory.

So 2 solutions we can update both value in same time, or use 2 parts in the DDF. I think the easier is the second one

        {
          "name": "state/lightlevel",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 104,
            "eval": "const lux = Attr.val; if (lux > 0 && lux < 0xffff) {Item.val = Math.round(10000 * Math.log10(lux) + 1);};",
            "fn": "tuya"
          },
          "default": 0
        }
BabaIsYou commented 1 year ago

One thing to note is that DDF got default duration as "90" but once paired I got it as "600" but I changed it via HA..

Value was taken from documentation …Here … weird but can be changed if needed to reflect reality.

mprajsler commented 1 year ago

One thing to note is that DDF got default duration as "90" but once paired I got it as "600" but I changed it via HA..

Value was taken from documentation …Here … weird but can be changed if needed to reflect reality.

Hi, yeah same is for sensitivitymax where default is 1000 but I got 600 after pairing.

mprajsler commented 1 year ago

Ok so It seem it's not mandatory.

So 2 solutions we can update both value in same time, or use 2 parts in the DDF. I think the easier is the second one

        {
          "name": "state/lightlevel",
          "read": {
            "fn": "none"
          },
          "parse": {
            "dpid": 104,
            "eval": "const lux = Attr.val; if (lux > 0 && lux < 0xffff) {Item.val = Math.round(10000 * Math.log10(lux) + 1);};",
            "fn": "tuya"
          },
          "default": 0
        }

Done and here are the results, seems OK to me thanks image image

A cosmetic one but what to do with this? As mentioned it is not under /lights no more but reported as plug here? image

mprajsler commented 1 year ago

Snímek obrazovky 2022-12-29 v 13 52 34

this is OK?

BabaIsYou commented 1 year ago

Sensitivitymx is a RW item In code and in DDF.

may be a conflict with different range definition in item and DDF ?

Smanar commented 1 year ago

It's the device itself that presente itself as "Smart plug", we can change that in the API, but deconz show only the reality.

Smanar commented 1 year ago

Ha nice there is a problem with sensitivitymax

It was marked as RW here


{
    "schema": "resourceitem1.schema.json",
    "id": "config/sensitivitymax",
    "datatype": "UInt8",
    "access": "RW",
    "public": true,
    "range": [0, 255],
    "description": "The maximum sensor sensitivity."
}

But the code prevent the value be modified


            // Changing these values of zigbee sensors is not allowed, read-only.
            if (rid.suffix == RConfigPending || rid.suffix == RConfigSensitivityMax || rid.suffix == RConfigHostFlags || rid.suffix == RConfigLastChangeAmount ||
                rid.suffix == RConfigLastChangeSource || rid.suffix == RConfigLastChangeTime || rid.suffix == RConfigEnrolled ||
                (!isClip && (rid.suffix == RConfigBattery || rid.suffix == RConfigReachable)))
            {
                rsp.list.append(errorToMap(ERR_PARAMETER_NOT_MODIFIABLE, QString("/sensors/%1/config/%2").arg(id).arg(pi.key()),
                                           QString("parameter, %1, not modifiable").arg(pi.key())));
                continue;
            }
BabaIsYou commented 1 year ago

Well, is the « bug » in the code or in the json ;-) ?

Smanar commented 1 year ago

I have asked to other dev. And the problem is in the json.

The editable setting is config/sensitivity. The value in config/sensitivitymax is not editable, it's the maximum value that can be used for config/sensitivity.


        {
          "name": "config/sensitivitymax",
          "description": "Far detection sensitivity in cm. From 0 to 1000. Default 1000",
          "range": [0, 1000],
         "read": {
            "fn": "none"
          },
          "write": {
            "dpid": 4,
            "dt": "0x2b",
            "eval": "Item.val;",
            "fn": "tuya"
          },
          "parse": {
            "dpid": 4,
            "eval": "Item.val = Attr.val;",
            "fn": "tuya"
          }
        },

It's because the missing field "config/distance" (for exemple), but not possible use this one . There is "config/triggerdistance" but this one need a string, and I don't see another usable ....

Edit: I think it's possible with "config/triggerdistance" and using string like "hight"/"low"/"medium" and predefined value, like here https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/ikea/starkvind_air_purifier.json for the "config/mode".

BabaIsYou commented 1 year ago

I think it’s a good idea. The expected value is in cm, but we can propose a string value in meter, from 0 to 10 with increment of 1 ?

Smanar commented 1 year ago

For me 0 to 5 is enought

manosioa commented 1 year ago

Happy New Year everyone!

I see there is some progress with some of the device's functions.

As I do not understand most of the posts, can someone provide a full DDF to upload to my devices? Also please tell me what you need me to test and try out if you need help :)

Thanks

BabaIsYou commented 1 year ago

The value in config/sensitivitymax is not editable,

Well, then just to understand, why has it been stated as config and not as state if it can't be modified and writable in the json ? Seems weird for me.

mprajsler commented 1 year ago

Can config/triggerdistance from this DDF be picked up somehow? https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/xiaomi/xiaomi_rtczcgq11lm_fp1_presence_sensor.json

BabaIsYou commented 1 year ago

For me 0 to 5 is enought

May be, it doesn't really matter.

Tried to reproduce what is in https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/ikea/starkvind_air_purifier.json but realized that this example use a integer value (config/mode) to be written. Here, if we used config/sensitivitymax, we will try to use a string value while the attended value passed to tuya function is datatype "dt": "0x2b".

mprajsler commented 1 year ago

OK and this wil cover the "Far detection" as per standard tuya app? https://blakadder.com/assets/images/zy-m100/tuya_app.jpg