dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.89k stars 496 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

Smanar commented 2 years ago

So all seem fine 0x00 mean IAS_ACE_PANEL_STATUS_PANEL_DISARMED If you do the same thing with the alarm armed the result will be 0x01 0x02 or 0x03

But perhaps the tags just prevend you using a code ? so you need to press armed or disarmed after having using the tag no ?

ZeppDK commented 2 years ago

if i just press lock or unlock button it says code length 0 but if i use a tag first, and then press lock or unlock it says code length 9 so i guess your right, but i still dont now how to capture that code, so that i can add them to the allowed codes :) billede

Smanar commented 2 years ago

Ha yessssss ^^, good catch. There is an hidden code somewhere to reconize good and bad rfid. There is nothing on the documentation ? to add or remove a RFID ? I don't think it s something coded hardware.

For security reason, the code never appear. I can make a change to display it if you can compile the code. But I think we can catch it using the GUI, need to check.

But the problem is the same, need to be implemented in the api to be used by third app.

Can you check if you have information in the documentation ? I think there is something to add or remove a RFID so perhaps a way to add code with an invisible/securised way. Perhaps need to use the application ? So we miss a way to add code "by the device itslef", for exemple use "add new rfid" in HA and show the TAG on the keypad.

ZeppDK commented 2 years ago

I have looked more than once in the documentation, and keyforbs are mentioned multiple times, but i cant find any hint on how to add/configure them in deconz

Smanar commented 2 years ago

but i cant find any hint on how to add/configure them in deconz

In deconz it s missing for sure, need some code, but need to mimic the "normal" way. You haven't the procedure with the original gateway ? It probably something like

ZeppDK commented 2 years ago

I Can find some indikation that it should work with smartthings, and maybe something called “squid.link 2x”… but only part interesting info was this datasheet https://www.develcoproducts.com/media/2032/kepzb-110-technical-manual-keypad.pdf

ZeppDK commented 2 years ago

But its still not saying much about the rfid reader

Smanar commented 2 years ago

I need to ask manup the direction to take.

BTW, can you share your DDF for other ?

ZeppDK commented 2 years ago

It would be nice to have multiple pins (and maybe somehow asign them to a user, so you Can see who is disabling the alarm, and easy disable a user/code if its not used anymore)

Yes, i Will post the DFF

ZeppDK commented 2 years ago

my DFF { "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", "public": true }, { "name": "state/tampered" } ] } ] }

Smanar commented 2 years ago
{
  "schema": "devcap1.schema.json",
  "manufacturername": "Develco Products A/S",
  "modelid": "KEPZB-110",
  "product": "KEPZB-110",
  "sleeper": false,
  "status": "Bronze",
  "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",
          "public": true
        },
        {
          "name": "state/tampered"
        }
      ]
    }
  ]
}
Smanar commented 2 years ago

So I need to take a look on code, but I will make a command for the alarm system will be able to learn code (this one will be invisible for security reason)

BTW I haven't asked, are you able to compile the code for tests ? (Need a linux machine with full/real OS)

ZeppDK commented 2 years ago

yep, i have multiple linux hosts...

Smanar commented 2 years ago

Perfect, so it will be step by step because I m asking which one request to use for the API (don't want to re write all because of a bad choice)

You have the procedure here https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Compiling-the-REST-plugin-for-device-specific-testing So for you, after having installed deconz (The code is based on realy last one, so need a recent version):

sudo apt install deconz-dev
git clone --branch keypad_rfid https://github.com/Smanar/deconz-rest-plugin.git
cd deconz-rest-plugin
qmake && make -j2
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins

If you have a small raspberry, it can freeze during compilation, my pi 3 do, so remove "-j2"

So what do this code :

Can try to catch the code used by the RFID, try to add it in index 1, and use it, you will have lots of usefull logs.

ZeppDK commented 2 years ago

okay, i can see the code: billede

but i cant seem to get the syntax for putting in the code ...

i have tried what you sugested billede

i also tried the same way i added code0 billede

ZeppDK commented 2 years ago

this worked

billede

ZeppDK commented 2 years ago

i have now added 2 rfid tags in position 1 and 2, and can use them both, and also the pin, so it seems to be working.

Smanar commented 2 years ago

Lol, serioulsy ? on first try ? BTW you have hidded the RFID code ^^, but there is something common to them ? like the start by "+" ? It's realy something new, first time I m seing that.

Now need to make that naturally, I will ask if we need to put the keypad in "learn mode" or " the alarm system.

ZeppDK commented 2 years ago

Yes, they start with “+”, and so far 8 numbers or letters after the +

ZeppDK commented 2 years ago

I have an idea.. maybe its a its a good idea to also allow the code to be a combination of an RFID tag and a pin code so something like +33AB33AB1234 This would give 2 factor Security, even if someone find a tag it would be unusable without the pin

ZeppDK commented 2 years ago

okay, just testet the above idea, and even though i used the rfid tag first to activate the panel, and then pressed a code, in the log it was pressented the other way around like this...

billede

ZeppDK commented 2 years ago

i have tried adding it like in the debug output, and it works...

billede

Smanar commented 2 years ago

Ha yes , nice find.

I m still waiting Manup answer to not take a bad way.

Smanar commented 2 years ago

Manup have an idea. On smartphone, there is RFID reader application, I have one ATM (MIFARE Calssic tool). Can you try this kind of application with you RFID tag ? To see if you can obtain the code like that ?

ZeppDK commented 2 years ago

I cant seem to find an iPhone app that Can read mifare classic without an external reader

Smanar commented 2 years ago

This one seem free https://apps.apple.com/fr/app/mtools-ble-rfid-reader/id1531345398 ?

ZeppDK commented 2 years ago

and it doesnt seem to read any of the mifare tags i have...

Smanar commented 2 years ago

Arf, nothing happen when you put the RFID on the phone ?

ZeppDK commented 2 years ago

No, i cant find any app that gets the iPhone to get any info from a tag.. it does not see anything at all

Smanar commented 2 years ago

Hello, just some news, so I can't let the code displayed in logs, even just for RFID, because this always haunts people later as it lands in debug logs on forums/GH. And I m agree with that.

But I have the autorisation to make a request to learn the code, something like PUT /api/<apikey>/alarmsystems/<id>/learncode

And BTW, I probably need your help later, somes users want to re add the removed ZHAPresence sensor from keypad.

ZeppDK commented 2 years ago

As long as a code can be learned, im shure that would be fine.. Is there any way to see the ID of what user have used a code?

What is the ZHAPresence for?

Smanar commented 2 years ago

What is the ZHAPresence for?

Simple, this device send a presence notification when the user is in front of the keypad, and somes user use this notification. I think it can work just with adding a ZHApresence on the DDF and configure it like a motion sensor that use the ias cluster, but will see later.

Have updated the code again (and removed the log that display code)

// PUT /api/<apikey>/alarmsystems/<id>/learncode/<index>

Index > 0 (code0 is reserved), but idk if it s possible tu use PUT without body ....

and after that just type a code or show a rfid tag then press arm or disarm

You will have an error, bad code used, but it will be memorised at the index.

Logs will be visible with "ias" and "info".

ZeppDK commented 2 years ago

its not happy with that :) billede

Smanar commented 2 years ago

Arf, my bad, can you make a new try ?

ZeppDK commented 2 years ago

it writes the following error back, but it works perfekt. i can add a tag, a code, or both in combination, just like the manual test... image

ZeppDK commented 2 years ago

just an idea, for the common user, would it make sense to put the learn funktion into the phoscon interface? so that people dont need to get an api key, and installing something like postman only for adding codes to their alarm system :-)

Smanar commented 2 years ago

Thx, corrected on my side. I will add a way to delete key, a timer to disable the learn mode and I will explain you how to test the presence sensor.

Phoscon don't support alarm system yet, But I think third app will support it faster. And for the moment the code is only a proof of concept as all PR are locked.

Smanar commented 2 years ago

Ok so updated the code

DELETE /api/<apikey>/alarmsystems/<id>/config/code with as body {index,code}

You need to use the correct index and code to be able to remove it (else its also possible with code0, if you forget it)

For the sensor entry, just try adding a ZHAPresence on your DDF, will see if the legacy is enought to make it working. No sure It will work wihout binding/reporting too ....

ZeppDK commented 2 years ago

If you need the code to delete it, what if you loose a tag? Then you have no way to get the code

Smanar commented 2 years ago

It s also possible with code0, the master code. Just use the id you want to delete and the master code.

mathieuvanloon commented 2 years ago

Hi there! Really great to see you're working on this device!

Is it correct that there is no support for the keypad yet in the regular home assisstant / deconz release? I'm running on a raspberry pi and I can't find a way to import the DDF you're using to get the keypad up and running. Do you happen to know a way around that?

many thanks!

mathieu

Smanar commented 2 years ago

Yep you can use the DDF to use this device https://github.com/dresden-elektronik/deconz-rest-plugin/issues/5352#issuecomment-1023315714 You can just use a "file manager" to create the file.

But you will not have the last features like the RFID tag stuff.

ZeppDK commented 2 years ago

when i try the delete option on slot 4, and try using the master pin (code0) i get this error billede

Smanar commented 2 years ago

There is a typo, it's not "," but ":" in the body.

ZeppDK commented 2 years ago

aahh, then it worked :-)

ZeppDK commented 2 years ago

i added ZHAPresence to the DDF, and now it blinks in the deconz gui eatch time the pannel is sensing presence, so it seems to work :-)

Smanar commented 2 years ago

Seriously ? on first try ? nice. I will say that in the other topic.

As the DDF is working without code edition, do you want to make a PR with just DDF ? You are using the first working DDF for keypad, can be usefull for other. Else I can do it, but better to use your name.

ZeppDK commented 2 years ago

Seriously ? on first try ? nice. I will say that in the other topic.

As the DDF is working without code edition, do you want to make a PR with just DDF ? You are using the first working DDF for keypad, can be usefull for other. Else I can do it, but better to use your name.

what do you mean by PR?

Smanar commented 2 years ago

Pull Request https://github.com/dresden-elektronik/deconz-rest-plugin/pulls

Smanar commented 2 years ago

Hello, so wana make it, or you prefer I made it ?