dresden-elektronik / deconz-rest-plugin

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

Konke Kit Pro Multi Function Button #3339

Closed Doreinie closed 3 years ago

Doreinie commented 4 years ago

Konke Kit Pro Multi Function Button

Screenshots

image image image image image image

I hope this request is now accepbtable. Not that easy for a newbie to get this done. but Yeah! got so far and hope to have the buttons added some time soon. Thanks

Mimiix commented 4 years ago

@SwoopX Can you check if this is correct?

Doreinie commented 3 years ago

@Mimiix what is the netx step? Are you taking this item on as a candidate into deconz / Phoscon?

SwoopX commented 3 years ago

Info should be complete from what I can tell. I can't take care of that since I got tons of local PRs waiting with significant dependencies.

Mimiix commented 3 years ago

@Doreinie We need people like Swoop to integrate it. Or you have to do it yourself. They do this in their spare time so i really can't obligate them to do it.

Doreinie commented 3 years ago

@Mimiix is there any sample on what is needed to do to integrate the Konke item by myself. Then I can try it

Mimiix commented 3 years ago

@SwoopX Is best to explain that.

SwoopX commented 3 years ago

What makes you think that?

Erik made a nice short overview on this https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2061#issuecomment-568191933 However, point 2 and 3 are not necessary and more and got simplified by the entries in button_maps.json.

stale[bot] commented 3 years ago

As there hasn't been any response in 21 days, this issue has been automatically marked as stale. At OP: Please either close this issue or keep it active It will be closed in 7 days if no further activity occurs.

stale[bot] commented 3 years ago

As there hasn't been any response in 28 days, this issue will be closed. @ OP: If this issue is solved post what fixed it for you. If it isn't solved, request to get this opened again.

itairaz1 commented 3 years ago

+1 Is there any thing new about that? @SwoopX / @Mimiix can you please re-open this? If need any assistant, I can try help

opechunka commented 3 years ago

Any updates? It seems like it's not supported yet by the latest deconz.

rfilmyer commented 2 years ago

This button is supported by Zigbee2MQTT, which may be useful to deconz as a possible reference implementation for the protocol. One complication to note is that Konke devices only operate on channels 15, 20, and 25.

Doreinie commented 1 year ago

Hi guys, did not follow up my issue here as I was busy with other projects. I still have 2 of these switches and would like to revisit the topic to get them work with deconz. Maybe someone can help me or guide me how to do this? thanks!

Mimiix commented 1 year ago

Hi guys, did not follow up my issue here as I was busy with other projects. I still have 2 of these switches and would like to revisit the topic to get them work with deconz. Maybe someone can help me or guide me how to do this? thanks!

It's been 3 years.

@Smanar can you help out ?

Doreinie commented 1 year ago

yes @Mimiix, it has been a while. Those days back, I was not able to figure out how to do this by myself, finally ran out of time. Maybe, now it is a bit easier? I´m a bit more patient with myself in learning how to get the switches integrated. With some help and guidance from @Smanar ?

Smanar commented 1 year ago

Can try this DDF

{
  "schema": "devcap1.schema.json",
  "manufacturername": "Konke",
  "modelid": "3AFE280100510001",
  "product": "Konke Kit Pro Multi Function Button",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_SWITCH",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0006"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "refresh.interval": 86400,
          "awake": true,
          "parse": {
            "at": "0x0020",
            "cl": "0x0001",
            "ep": 1,
            "eval": "const vmin = 20; const vmax = 30; var bat = Attr.val; if (bat > vmax) { bat = vmax; } else if (bat < vmin) { bat = vmin; } bat = ((bat - vmin) / (vmax - vmin)) * 100; if (bat > 100) { bat = 100; } else if (bat <= 0)  { bat = 1; } Item.val = bat;",
            "fn": "zcl"
          }
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/buttonevent"
        },
        {
          "name": "state/lastupdated"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0006"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0020",
          "dt": "0x20",
          "min": 3600,
          "max": 3600
        }
      ]
    }
  ]
}

Then include the device, go in deconz logs (help/Debug view) enable flag "info" + "info_l2', and press button, you will have error message about missing button map, I just need them with the pressed button.

Mimiix commented 1 year ago

Can you remove this logs and please use pastebin for these large logs?

Doreinie commented 1 year ago

Added the DDF: Debug.txt in https://pastebin.com/QPHVpwL4

Smanar commented 1 year ago
18:44:12:172 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001080, zclSeq: 102
18:44:48:553 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001082, zclSeq: 106
18:45:05:767 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001081, zclSeq: 107

Now the hard part, will be not possible if you have HA.

Need to add in the button_maps.json file.

        "konkeMap": {
            "vendor": "Konke",
            "modelids": "3AFE280100510001",
            "map": [
                [1, "0x01", "ONOFF", "ATTRIBUTE_REPORT", "0x80", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "Normal press 1"],
                [1, "0x01", "ONOFF", "ATTRIBUTE_REPORT", "0x81", "S_BUTTON_2", "S_BUTTON_ACTION_SHORT_RELEASED", "Normal press 2"],
                [1, "0x01", "ONOFF", "ATTRIBUTE_REPORT", "0x82", "S_BUTTON_3", "S_BUTTON_ACTION_SHORT_RELEASED", "Normal press 3"]
            ]
        },

But I have a doubt on the payload, I think I need the full one and not just 0x08

Can you try this DDF, your device is simple, I think it's possible without buttonmap

{
  "schema": "devcap1.schema.json",
  "manufacturername": "Konke",
  "modelid": "3AFE280100510001",
  "product": "Konke Kit Pro Multi Function Button",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_SWITCH",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0006"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "refresh.interval": 86400,
          "awake": true,
          "parse": {
            "at": "0x0020",
            "cl": "0x0001",
            "ep": 1,
            "eval": "const vmin = 20; const vmax = 30; var bat = Attr.val; if (bat > vmax) { bat = vmax; } else if (bat < vmin) { bat = vmin; } bat = ((bat - vmin) / (vmax - vmin)) * 100; if (bat > 100) { bat = 100; } else if (bat <= 0)  { bat = 1; } Item.val = bat;",
            "fn": "zcl"
          }
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/buttonevent",
          "awake": true,
          "parse": {
            "cl": "0x0006",
            "cmd": "0x0A",
            "eval": "Item.val=(ZclFrame.at(4)-121)*1000+2"
          }
        },
        {
          "name": "state/lastupdated"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "dst.ep": 1,
      "cl": "0x0006"
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0020",
          "dt": "0x20",
          "min": 3600,
          "max": 3600
        }
      ]
    }
  ]
}

payload: 00001081 "eval": "Item.val=(ZclFrame.at(4)-121)*1000+2"

I m trying to convert the 81 to "1002" value

Doreinie commented 1 year ago

Thank you for the guidance I hope I did this all correctly. a) replaced the DDF with recent provided b) added info to the button_maps.json file image c) I was not sure if I have to add the payload info anywhere, I do not see any status change e.g. in iobroker when pression a button. image d) what do you mean with HA which would be bad? Do you need another log? thanks

Smanar commented 1 year ago

what do you mean with HA which would be bad?

It's realy hard to edit the buttonmap file on HA because of the docker use. How have you done that ? You have direclty edited the file on the docker ? And with the last DDF you don't need to edit the buttonamp file ^^

Can you just enable log "info" "info_l2" "DDF" and press device button with the new DDF ?

Doreinie commented 1 year ago

I´m not using docker. I have installed this directly on rasp pi 4b. now I think that with "HA" you mean "home assistant". I´m not using that. I use ioBroker. So I edit the file using "nano" or file editor. I did edit the DDF and the button_map file. This is how I understood the instructions. Is that wrong, only to change the DDF an not the button map file? log pastebin here: https://pastebin.com/w7fLRQX6 thank you Interesting is that the battery of the switches moved from green to red over night.

image

Smanar commented 1 year ago

Ha nice ^^. So yes it's easy on your OS, but this device use only 3 events and all on same command so easier using only DDF too

15:09:08:041 APS-DATA.indication from child 0x01EC
15:09:08:051 failed to evaluate expression for 14:b4:57:ff:fe:09:7c:cf-01-0006/state/buttonevent: Item.val=(ZclFrame.at(4)-121)*1000+2, err: RangeError: index out of range
15:09:08:056 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001080, zclSeq: 13

So the buttonamp haven't worked, but I think we can avoid them And the javascript expression have failed, I think it's because the first byte is 0 and not 1 payload: 00001080 0 > 00 1 > 00 2 > 10 3 > 80

So the code need to be

"eval": "Item.val=(ZclFrame.at(3)-121)*1000+2"

Doreinie commented 1 year ago

thanks, now I´m getting a button response. in iobroker I see single click response= 7002 double click response = 8002

this took a while until this was possible: long click upon release = 9002, have to hold the switch min 5 seconds

Is there a possibility to capture as well the "buttonpressed"? the response in iobroker only comes upon release. with the same number as response 7002, 8002, 9002

little log: https://pastebin.com/tJNUbaWf

Will it actually be possible to use the switch in Phoscon? e.g. link in phoscon web interface to connect in switch editor? Currently this is not possible!

Smanar commented 1 year ago

I don't have impact on phoscon, so you need to ask phoscon devs.

Is there a possibility to capture as well the "buttonpressed"?

From that I m reading this device have only 3 events. And I m using bad one ^^ https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Supported-Devices#events-legend

Need to have

single click response= 1002 double click response = 1004 long clic response = 1003

Can you try this eval code ? "eval": "const t={'128':2,'129':4,'130':3};if(ZclFrame.at(3) in t){Item.val=1000+t[ZclFrame.at(3)]}"

Doreinie commented 1 year ago

This is working. Great! single click response= 1002 double click response = 1004 long click response = 1003 I have tried to see if there is any other output for mutiple button presses, but there seems nothing. It goes that far that if I do 3 or more clicks the entire input is going to be ignored.

Do you know who to connect with to show in the web app the product info, switch status?

image

thank you!

Smanar commented 1 year ago

I have tried to see if there is any other output for mutiple button presses, but there seems nothing. It goes that far that if I do 3 or more clicks the entire input is going to be ignored.

Yeah the only zigbee request send by yur device are

18:44:12:172 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001080, zclSeq: 102
18:44:48:553 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001082, zclSeq: 106
18:45:05:767 [INFO] - No button map for: 3AFE280100510001, unicast to: 0x0000, endpoint: 0x01, cluster: ONOFF (0x0006), command: ATTRIBUTE_REPORT (0x0A), payload: 00001081, zclSeq: 1071

So only 3 actions.

Do you know who to connect with to show in the web app the product info, switch status?

I m not sure to understand, but you can see btton event in phoscon using help/API Information/event/sensor/ The device id.

But If I m right you can use them with ioBroker ? (better than Phoscon)

Doreinie commented 1 year ago

Yes, it seems we have max 3 actions and we got this working. Thank you!

To have it nice and neat it would be nice to have this more complete implemented in the phoscon web app and mobile app. I thought that this is done through the DDF but seems not.

Functionality in iobroker is available and all other stuff in phoscon would just be a plus.

Smanar commented 1 year ago

Do you want to make the PR or want I make it to include this device officialy ? And yes, I understand, but phoscon is a closed application and IDK what happen for them.

Doreinie commented 1 year ago

what is a PR? Yes, it would be great if the device would be included officially in the long run.

Smanar commented 1 year ago

You have it here https://github.com/dresden-elektronik/deconz-rest-plugin/pull/6946

Doreinie commented 1 year ago

Thank you for taking this forward