dresden-elektronik / deconz-rest-plugin

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

Frient intelligente KeyPad #5352

Closed Maxcrouz73 closed 8 months ago

Maxcrouz73 commented 2 years ago

Hello there, this is my first contribution to this great software, hope i do this correctly.

Device

Clusters of the node

Node info panel

Basic Clusters

Basic

Basic Clusters

Identify

Identify

Poll Contro

Poll Control l

IAS Zone

IAS Zone

Power Configuration

Power configuration

ZeppDK commented 2 years ago

I have no idea how to make it 😅

Smanar commented 2 years ago

Else I can do it, as you are the owner, need your autorisation.

ZeppDK commented 2 years ago

Thats ok, you can do it 😅

Smanar commented 2 years ago

ok ^^ But I need the DDF too :), there is not the last one with the presence sensor.

ZeppDK commented 2 years ago

{ "schema": "devcap1.schema.json", "manufacturername": "Develco Products A/S", "modelid": "KEPZB-110", "product": "KEPZB-110", "sleeper": false, "status": "Draft", "path": "/devices/KEPZB-110.json", "subdevices": [ { "type": "ZHAAncillaryControl", "restapi": "/sensors", "uuid": [ "$address.ext", "0x2c", "0x0501" ], "fingerprint": { "profile": "0x0104", "device": "0x0401", "endpoint": "0x2C", "in": [ "0x0000", "0x0001", "0x0500" ], "out": [ "0x0501" ] }, "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", "description": "The current device battery level in 0–100 %." }, { "name": "config/enrolled", "public": false, "description": "State of IAS enrollment process." }, { "name": "config/on" }, { "name": "config/pending", "description": "Pending tasks to configure the device." }, { "name": "config/reachable" }, { "name": "state/action", "public": false }, { "name": "state/lastupdated" }, { "name": "state/lowbattery", "description": "True when the device battery runs low." }, { "name": "state/panel", "default": "exit_delay" }, { "name": "state/tampered" } ] }, { "type": "$TYPE_PRESENCE_SENSOR", "restapi": "/sensors", "uuid": [ "$address.ext", "0x01", "0x0406" ], "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/duration", "description": "The duration until presence is automatically turned back to false." }, { "name": "config/on" }, { "name": "config/reachable" }, { "name": "state/lastupdated" }, { "name": "state/presence", "description": "True when presence is detected." } ] } ] }

Smanar commented 2 years ago

Done, thx a lot https://github.com/dresden-elektronik/deconz-rest-plugin/pull/5850

Have changed the file name according to previous one.

ZeppDK commented 2 years ago

@Smanar any idea when the RFID code will be in the beta/master? i talked to someone testing the beta, and he cant use the learn funktion you coded

Smanar commented 2 years ago

Oups I forget it. ATM most of the code is only for DDF, but I will make a PR, hoping for manup decision/corrective.

https://github.com/dresden-elektronik/deconz-rest-plugin/pull/5918

Smanar commented 2 years ago

Hello, some one here is able to send arm state to the alarmsystem endpoint ? The keypad mode is updated too in same time ?

Gw3n4 commented 2 years ago

Hello Smanar, Yes it works. I use Jeedom as my home automation system, and when I arm the alarmsystem endpoint with curl -H "Content-Type: application/json" -X PUT -d "{\"code0\": xxxx}" http://@IP:port/api/API_key/alarmsystems/1/arm_away it does update the keypad mode as well : the panel info goes from disarmed to exit_delay, then arming_away (only stays a very short time) and finally armed_away. Can't wait to get the RFID part working as well :) Thank you for your work !

Smanar commented 2 years ago

It mean you are Idaho947 ? (Or there is 2 users with exactly the same problem ^^ ?)

Gw3n4 commented 2 years ago

I am not Idaho947 but I think any user that has this keypad & wants to use RFID tags to arm/disarm the alarmsystem needs to have #5918 implemented, so it should not be just 2 users that are interested in having multiple codes registered in the alarm system endpoint in order to be able to configure the RFID tags' UID as codes. Or I missed something and there is already a way to do that?

Smanar commented 2 years ago

Nope you are right, but ATM I m with an user on jeedom too, that is doing exactly like you. I will ask if I can do something to speed up this PR.

Smanar commented 2 years ago

Manup will probalby take a look on the PR (around the version v2.18.3), so I m tryingto clean some part. Have tried to finish the timer part, if someone can make a test ?

If you can try in less than 60s, then more than 60s ?

Idaho947 commented 2 years ago

Hey guys I m here ! Gw3n4 how can I contact you ? I ve some question about your intégration of this keypad in jeedom. For me the panel always stay on exit_panel when I arm the alarm system via API.

Gw3n4 commented 2 years ago

@Idaho947 : have you added the keypad to the alarmsystems? with curl -H "Content-Type: application/json" -X PUT -d "{}" http://aaa.bbb.ccc.ddd:pppp/api/APIKEY/alarmsystems/1/device/aa:bb:cc:dd:ee:ff:gg:hh-2c-0501

Idaho947 commented 2 years ago

Yes I ve had it. Everything works fine. Only the panel always stay on exit_panel

Smanar commented 2 years ago

To describe the issue if I have understand (can be the normal result)

But need perhaps to make the keypad react to presence ?

Idaho947 commented 2 years ago

We talked and his keypad is a develco, mine a frient. The same design but not the same brand. Maybe they change something. For @Gw3n4 the panel action information on the keypad changed when the alarm system change with api. Forme it always stay on exit_panel

Smanar commented 2 years ago

Ha ? But develco and frient make same hardware no ? You are using same request ? it s not because one of you stay behind the keypad and not the other ?

Same DDF ?

Idaho947 commented 2 years ago

I thought it was the same but not sure now. We use the same request and ddf. I ll try to delete and include the keypad again without changing the ddf (now everything is ok with except the panel command). What i don't understand is that on his ddf the public part of action is set to false while i had to set it to true for the commands to be displayed at home

Smanar commented 2 years ago

Ha yes right, I forget that, I just make a PR https://github.com/dresden-elektronik/deconz-rest-plugin/pull/6189 But It have an impact on third app only, not on zigbee side.

Gw3n4 commented 2 years ago

We talked and his keypad is a develco, mine a frient. The same design but not the same brand. Maybe they change something.

No my keypad is a frient as well. Only the DDF I used had "manufacturername":"Develco Products A/S" & "vendor": "Develco Products" but it still works fine with my frient keypad.

it s not because one of you stay behind the keypad and not the other ?

When I perform the test, I am not in front of the keypad (and thus paid no attention to the led state) --> I checked the panel state change directly in Jeedom and it updates fine.

Idaho947 commented 2 years ago

Mine the manufacture name is realy "frient" on the guid so I have to change this part of the ddf.

Smanar commented 2 years ago

I don't understand why there is different working mode. The keypad is a passive device, so every time he want to display something it ask for status to alarm system, it don't memorise status.

So if the alarm system is armed, the keypad need to show the armed state.

Logs are easy to catch, just need to enable "IAS" log. When the device ask for the status to display you will see in log

DBG_Printf(DBG_IAS, "[IAS ACE] 0x%016llX panel status response: 0x%02X\n", ind.srcAddress().ext(), panelStatus);

And I don't remember a special missing bind ....

Idaho947 commented 2 years ago

My log where I wake up the keypad: image

Smanar commented 2 years ago

Here you have all value

#define IAS_ACE_PANEL_STATUS_PANEL_DISARMED           0x00
#define IAS_ACE_PANEL_STATUS_ARMED_STAY               0x01
#define IAS_ACE_PANEL_STATUS_ARMED_NIGHT              0x02
#define IAS_ACE_PANEL_STATUS_ARMED_AWAY               0x03
#define IAS_ACE_PANEL_STATUS_EXIT_DELAY               0x04
#define IAS_ACE_PANEL_STATUS_ENTRY_DELAY              0x05
#define IAS_ACE_PANEL_STATUS_NOT_READY_TO_ARM         0x06
#define IAS_ACE_PANEL_STATUS_IN_ALARM                 0x07
#define IAS_ACE_PANEL_STATUS_ARMING_STAY              0x08
#define IAS_ACE_PANEL_STATUS_ARMING_NIGHT             0x09
#define IAS_ACE_PANEL_STATUS_ARMING_AWAY              0x0a

So on your exemple, when you have wake up the device it need to show the disarmed state ?

Idaho947 commented 2 years ago

Yes it was disarmed but the panel is still on exit_delay. image

Smanar commented 2 years ago

Ha yes, I understand it's same problem than for state/action. In the logic it's a read only device like a switch, this kind of device send a notification when the user use it to make something on the automation side. But yes if you have a widget to mimic the panel that use state/panel, it will be updated only when the user use it, not when you force the arm status.

I m looking code to see what I can do. But it seem there is a fonction mirrorKeypadAlarmSystemState() used to mimic all action from alarm status to panel state ....

It's same for you @Gw3n4 I think ?

Smanar commented 2 years ago

Ha I have perhaps found the problem ^^

            ResourceItem *panel = r->item(RStatePanel);
            ResourceItem *secondsRemaining = r->item(RStateSecondsRemaining);

            if (!panel || !secondsRemaining) { continue; }

And on your capture you haven't state/seconds_remaining, so this code part is skipped.

I think @Gw3n4 have it on his DDF but not you. Try adding that in your DDF (and make a hot relaod)


            {
               "name":"state/seconds_remaining"
            },

This field is missing on json, so you can't add it using the editor, need to use a text editor.

Idaho947 commented 2 years ago

This is his ddf and i can t see it. { "schema":"devcap1.schema.json", "manufacturername":"Develco Products A/S", "modelid":"KEPZB-110", "vendor": "Develco Products", "product":"KEPZB-110 Keypad", "sleeper":false, "status":"Gold", "subdevices":[ { "type":"ZHAAncillaryControl", "restapi":"/sensors", "uuid":[ "$address.ext", "0x2c", "0x0501" ], "fingerprint":{ "profile":"0x0104", "device":"0x0401", "endpoint":"0x2C", "in":[ "0x0000", "0x0001", "0x0500" ], "out":[ "0x0501" ] }, "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" }, { "name":"config/enrolled", "public":false }, { "name":"config/on" }, { "name":"config/pending" }, { "name":"config/reachable" }, { "name":"state/action", "public":false }, { "name":"state/lastupdated" }, { "name":"state/lowbattery" }, { "name":"state/panel", "default":"exit_delay" }, { "name":"state/tampered" } ] }, { "type":"$TYPE_PRESENCE_SENSOR", "restapi":"/sensors", "uuid":[ "$address.ext", "0x01", "0x0406" ], "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/duration" }, { "name":"config/on" }, { "name":"config/reachable" }, { "name":"state/lastupdated" }, { "name":"state/presence" } ] } ] }

I'll try to had it tomorow

Idaho947 commented 2 years ago

Ok I had it on the ddf now it look at that. I'll try to test some alarm change but not today. ddffrient.txt An other thing, i change the batterie but the command always stay on 0. Some thing for the presence.

Smanar commented 2 years ago

i change the batterie but the command always stay on 0

It miss the binding for the batterry ....

Some thing for the presence.

Mean miss the battery ? Because there is a bad enpoint in the DDF too, and no config/battery.

Can you try this DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": [
    "Develco Products A/S",
    "frient A/S"
  ],
  "modelid": [
    "KEPZB-110",
    "KEPZB-110"
  ],
  "vendor": "Develco Products",
  "product": "KEPZB-110 Keypad",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "ZHAAncillaryControl",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x2c",
        "0x0501"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0401",
        "endpoint": "0x2C",
        "in": [
          "0x0000",
          "0x0001",
          "0x0500"
        ],
        "out": [
          "0x0501"
        ]
      },
      "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",
          "default": 0
        },
        {
          "name": "config/enrolled",
          "public": false
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/action",
          "default": "disarmed"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lowbattery"
        },
        {
          "name": "state/panel",
          "default": "exit_delay"
        },
        {
          "name": "state/seconds_remaining"
        },
        {
          "name": "state/tampered"
        }
      ]
    },
    {
      "type": "$TYPE_PRESENCE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x2c",
        "0x0406"
      ],
      "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/duration"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/presence",
          "default": false
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 44,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0021",
          "dt": "0x20",
          "min": 3600,
          "max": 43200,
          "change": "0x00000001"
        }
      ]
    }
  ]
}
Idaho947 commented 2 years ago

Sorry I wanted to say the same thing for the presence. It doesn't work and always stay at 0. I tried your new ddf but the batterie is always 0.

A new presence equipement is created.

But good news the panel is working !

Smanar commented 2 years ago

Ok So I will start to complete the PR with taht.

For the battery, it can need some time, I have set a long timer. Can try to read the value in the cluster 0x0001, attribute 0x0021. If it update the value in the API > binding problem Else > need to force some stuff in the DDF.

A new presence equipement is created.

Yeah, sorry, I forget to prevent you, I have used the same endpoint, so you have one with "01" and the other one with "2c", the first one is useless now.

I don't remember how it's working ... Perhaps I need a bind with the cluster 0x0500 to the gateway, nothing in logs with the flag "ias" and when passing close the sensor ?

Idaho947 commented 2 years ago

It's 0 : image

Yeah, sorry, I forget to prevent you.

No problem

Smanar commented 2 years ago

Have updated the PR https://github.com/dresden-elektronik/deconz-rest-plugin/pull/6189

But if the value is 0, it mean your device don't support it. You have pressed the "read" button, or double clic on the attribute and update it ? (You can have to wake up the device)

Can try to make the bind manualy or add this part on the DDF to make a bind (for the presence sensor)


  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 44,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0021",
          "dt": "0x20",
          "min": 3600,
          "max": 43200,
          "change": "0x00000001"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 44,
      "dst.ep": 1,
      "cl": "0x0500"
    }
  ]
}
Idaho947 commented 2 years ago

I press the read bouton and Thing have change : image I use your ddf and nothing change for the presence

Smanar commented 2 years ago

Arf so the attribute 0x0021 is not working, need to use the 0x0020 instead

{
  "schema": "devcap1.schema.json",
  "manufacturername": [
    "Develco Products A/S",
    "frient A/S"
  ],
  "modelid": [
    "KEPZB-110",
    "KEPZB-110"
  ],
  "vendor": "Develco Products",
  "product": "KEPZB-110 Keypad",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "ZHAAncillaryControl",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x2c",
        "0x0501"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0401",
        "endpoint": "0x2C",
        "in": [
          "0x0000",
          "0x0001",
          "0x0500"
        ],
        "out": [
          "0x0501"
        ]
      },
      "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",
          "default": 0
        },
        {
          "name": "config/enrolled"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/pending"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/action",
          "default": "disarmed"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/lowbattery"
        },
        {
          "name": "state/panel",
          "default": "exit_delay"
        },
        {
          "name": "state/seconds_remaining"
        },
        {
          "name": "state/tampered"
        }
      ]
    },
    {
      "type": "$TYPE_PRESENCE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x2c",
        "0x0406"
      ],
      "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/duration"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/presence",
          "default": false
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 44,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0020",
          "dt": "0x20",
          "min": 3600,
          "max": 43200,
          "change": "0x00000001"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 44,
      "dst.ep": 1,
      "cl": "0x0500"
    }
  ]
}

On the DDF I have too made the config/enrolled visible. For ias device, we need an enrollment, thoses field are for the ZHAAncillaryControl but not the ZHAPresence, because it have worked before like that before, but not sure it's the better solution.

When you have read the attribute on deconz, it have updated the value in the DDF or not ? The previous DDF make the bind, but idk if I need to be more precise for the config/battery.

Do you have something on logs with the flag" IAS" when the device detect you ?

Idaho947 commented 2 years ago

Yes I see the new bind in the deconz GUID in the ddf.

When it detect me that appears in the log IAS image

Smanar commented 2 years ago

Can you check the attribute 0x0000 in the cluster 0x0500 You need to have "enrolled".

I seriously don't remember how are working this device for the detection, I need to check on old code.

Smanar commented 2 years ago

Ok have found the old code https://github.com/Smanar/deconz-rest-plugin/blob/069a7e93c0e5a74da1395f7191b1c4a981167a23/ias_ace.cpp

And the sensor was updated during the CMD_GET_PANEL_STATUS, so I don't understand why it have worked for others devices.

But now I remember manup was not agree with this code part, and I don't remember why.

Idaho947 commented 2 years ago

The binding : binding

It's enrolled : enrolled

Smanar commented 2 years ago

Ok so from manup (he wasn't sure, it's realy old) the device make this kind of request periodicaly, evan if there is noone in front of it. The same on your capture here https://github.com/dresden-elektronik/deconz-rest-plugin/issues/5352#issuecomment-1184626024

You can check to be sure if it's right ?

Idaho947 commented 2 years ago

Yes it's right. the device send those line alone every 5min : image

When I'm in front of it it send : image

Smanar commented 2 years ago

The status 10 is STATUS_SUPERVISION, and I realy don't see the usage of it, not used in deconz code. But they are not same, the one "panel status response" never happen if there is no one close the keypad ?

I have found this code too https://github.com/arnbme/nyckelharpa/blob/master/Centralite-Keypad.groovy And they use the same request (panel status response) to trigger an motion sensor, so for me it's possible.

And BTW, why this sensor can be usefull ? Better to know if someone have tried to use a (bad) code ? You can have so much passage infront of the keypad, what you can do with this information ?

Idaho947 commented 2 years ago

In fact the keypad is juste on the right of my door so I can know if someone is at this place. It also be able to detect if someone is in front of the pad. I look at the long during several hour and I never see the "panel status response".

Smanar commented 2 years ago

K, I will go to ask again to manup if I can re add the presence sensor ^^

Smanar commented 2 years ago

Ok, so verdict, not possible sorry. He is working on some new features that can be used later for that, but not possible using c++ code to make the ZHAPresence working.

Idaho947 commented 2 years ago

OK, no worries