dresden-elektronik / deconz-rest-plugin

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

WXKG16LM Aqara E1 Wireless Switch, Single rocker #5862

Closed yeongsong closed 2 years ago

yeongsong commented 2 years ago

Device

Screenshots

Required screenshots:

Basic

image

Identify

image

Other clusters that are not mentioned above

image image image image

github-actions[bot] commented 2 years ago

As there has not 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.

github-actions[bot] commented 2 years ago

As there has not 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 is not solved, request to get this opened again.

yeongsong commented 2 years ago

Anyone able to help please?

Mimiix commented 2 years ago

@Smanar can this be done with ddf?

Smanar commented 2 years ago

lol, why you ask me ? it s not tuya stuff, this one have the lumi cluster, it s SwoopX hobby.

Seriously I don't know. I have some problem with battery switch (but have better results thoses days) and this one use the lumi cluster, I haven't found smilar device in actual DDF sample to be sure it's possible.

SwoopX commented 2 years ago

This one should probably make it fully functionable:

{
  "schema": "devcap1.schema.json",
  "manufacturername": "$MF_LUMI",
  "modelid": "lumi.remote.acn003",
  "matchexpr": "R.endpoints.length === 1",
  "vendor": "Xiaomi",
  "product": "Aqara E1 single rocker wireless switch WXKG16LM",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_SWITCH",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0006"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0000",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0x0001",
          "0x0012",
          "0xFCC0"
        ],
        "out": [
          "0x0006"
        ]
      },
      "meta": {"group.endpoints": [1] },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid",
          "awake": true
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "awake": true,
          "parse": {
            "at": "0x00f7",
            "ep": 1,
            "fn": "xiaomi:special",
            "idx": "0x01",
            "script": "xiaomi_battery.js"
          }
        },
        {
          "name": "config/clickmode",
          "refresh.interval": 3000,
          "parse": {
            "at": "0x0125",
            "cl": "0xfcc0",
            "ep": 1,
            "eval": "if (Attr.val == 1) { Item.val = 'highspeed' } else if (Attr.val == 2) { Item.val = 'multiclick' } else { Item.val = 'unknown' }",
            "fn": "zcl",
            "mf": "0x115f"
          },
          "read": {
            "at": "0x0125",
            "cl": "0xfcc0",
            "ep": 1,
            "fn": "zcl",
            "mf": "0x115f"
          },
          "write": {
            "at": "0x0125",
            "cl": "0xfcc0",
            "dt": "0x20",
            "ep": 1,
            "eval": "if (Item.val == 'highspeed') { 1 } else if (Item.val == 'multiclick') { 2 }",
            "fn": "zcl",
            "mf": "0x115f"
          },
          "values": [
            ["\"highspeed\"", "Buttons emit only single click events, but fast"],
            ["\"multiclick\"", "Emits single, double and treble presses"] 
          ],
          "default": "multiclick"
        },
        {
          "name": "config/devicemode",
          "refresh.interval": 3000,
          "parse": {
            "at": "0x0009",
            "cl": "0xfcc0",
            "ep": 1,
            "eval": "if (Attr.val == 1) { Item.val = 'compatibility' } else if (Attr.val == 2) { Item.val = 'zigbee' } else { Item.val = 'unknown' }",
            "fn": "zcl",
            "mf": "0x115f"
          },
          "read": {
            "at": "0x0009",
            "cl": "0xfcc0",
            "ep": 1,
            "fn": "zcl",
            "mf": "0x115f"
          },
          "write": {
            "at": "0x0009",
            "cl": "0xfcc0",
            "dt": "0x20",
            "ep": 1,
            "eval": "if (Item.val == 'compatibility') { 1 } else if (Item.val == 'zigbee') { 2 }",
            "fn": "zcl",
            "mf": "0x115f"
          },
          "values": [
            ["\"compatibility\"", "Default mode for Xiaomi devices"],
            ["\"zigbee\"", "Closer to zigbee standard"] 
          ],
          "default": "compatibility"
        },
        {
          "name": "config/group",
          "default": "auto"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/buttonevent"
        },
        {
          "name": "state/lastupdated"
        }
      ]
    }
  ]
}
Smanar commented 2 years ago

whoaaa. You have made this DDF from scratch ? or you already have used this code for another device ?

SwoopX commented 2 years ago

Looks pretty identical to the wireless H1 dual rocker I have here 🙂

github-actions[bot] commented 2 years ago

As there has not 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.

github-actions[bot] commented 2 years ago

As there has not 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 is not solved, request to get this opened again.

mcf68k commented 2 years ago

Hello, How can I make working the same switch but with 2 buttons (WXKG17LM) ? I already opened a new device request. Can you confirm this one is working (WXKG16LM) before I order one ? Thanks

yeongsong commented 1 year ago

Hello, How can I make working the same switch but with 2 buttons (WXKG17LM) ? I already opened a new device request. Can you confirm this one is working (WXKG16LM) before I order one ? Thanks

nope, didn't work. somehow my switch got bricked after several attempts to edit the settings.

Idechix commented 7 months ago

I've been struggling for several days to get that module to work with deconz, but to no avail. I've even tried adapting and modifying the DDF files of other similar modules like WXKG17LM and WXKG20LM without success. Each time, the battery level doesn't work, and I don't receive any events when I press the button.

Any insights or suggestions would be greatly appreciated. Thanks in advance for your help!

Smanar commented 7 months ago

Hello, what is your model id ? And a Cluster picture to see wich one version you have ?

Idechix commented 7 months ago

My model is lumi.remote.acn003 (WXKG16LM).

screenshot

I didn't notice earlier that there are more attributes listed in mine than in yeongsong's. Don't know if this has anything to do with the fact that mine doesn't work.

Smanar commented 7 months ago

So there is nothing in deconz for this device. You can try with this DDF https://github.com/dresden-elektronik/deconz-rest-plugin/issues/5862#issuecomment-1136459355

You will have a start of support, but you will need to edit too the button_maps.json file to add the device

If they are same device, and use same command can add your device in the WXKG17LM button map


        "xiaomiSwitchE1Acn004Map": {
            "vendor": "Xiaomi",
            "doc": "Xiaomi Aqara E1 dual rocker wireless switch WXKG17LM",
            "modelids": ["lumi.remote.acn004", "lumi.remote.acn003"],
Idechix commented 7 months ago

That still doesn't work. (I already tried that a few days ago, but I tried it again today)

I've tried everything I know to make it work properly:

As mentioned previously, the battery monitoring always reports 0, and there are no events sent when pressing the button.

Here are the only messages I receive from the websocket:

{"attr":{"id":"45", "lastannounced":null, "lastseen":"2024-03-16T15:25Z", "manufacturername":"LUMI", "mode":1, "modelid":"lumi.remote.acn003", "name":"Switch 45", "swversion":null, "type":"ZHASwitch", "uniqueid":"54:ef:44:10:00:7b:66:be-01-0006"}, "e":"changed", "id":"45", "r":"sensors", "t":"event", "uniqueid":"54:ef:44:10:00:7b:66:be-01-0006"}
{"config":{"battery":0, "clickmode":"multiclick", "devicemode":"unknown", "on":true, "reachable":true}, "e":"changed", "id":"45", "r":"sensors", "t":"event", "uniqueid":"54:ef:44:10:00:7b:66:be-01-0006"}
Idechix commented 7 months ago

I've created a slightly modified version of the DDF mentioned earlier, which closely resembles the current DDF for the WXKG17LM. Despite this, it still doesn't work. However, it could serve as a good starting point for experimentation.

{
  "schema": "devcap1.schema.json",
  "manufacturername": "$MF_LUMI",
  "modelid": "lumi.remote.acn003",
  "matchexpr": "R.endpoints.length === 1",
  "vendor": "Xiaomi",
  "product": "Aqara E1 single rocker wireless switch WXKG16LM",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_SWITCH",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0006"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0000",
        "endpoint": "0x01",
        "in": [
          "0x0000",
          "0x0001",
          "0x0012",
          "0xFCC0"
        ],
        "out": [
          "0x0006"
        ]
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid",
          "awake": true
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",
          "parse": {
            "at": "0x00f7",
            "ep": 1,
            "fn": "xiaomi:special",
            "idx": "0x08",
            "script": "xiaomi_swversion.js"
          },
          "read": {
            "fn": "none"
          }
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "awake": true,
          "parse": {
            "at": "0x00f7",
            "ep": 1,
            "fn": "xiaomi:special",
            "idx": "0x01",
            "script": "xiaomi_battery.js"
          }
        },
        {
          "name": "config/clickmode",
          "awake": true,
          "parse": {
            "at": "0x0125",
            "cl": "0xfcc0",
            "ep": 1,
            "eval": "if (Attr.val == 1) { Item.val = 'highspeed' } else if (Attr.val == 2) { Item.val = 'multiclick' } else { Item.val = 'unknown' }",
            "fn": "zcl:attr",
            "mf": "0x115f"
          },
          "read": {
            "at": "0x0125",
            "cl": "0xfcc0",
            "ep": 1,
            "fn": "zcl:attr",
            "mf": "0x115f"
          },
          "write": {
            "at": "0x0125",
            "cl": "0xfcc0",
            "dt": "0x20",
            "ep": 1,
            "eval": "if (Item.val == 'highspeed') { 1 } else if (Item.val == 'multiclick') { 2 }",
            "fn": "zcl:attr",
            "mf": "0x115f",
            "state.timeout": 2
          },
          "values": [
            ["\"highspeed\"", "Buttons emit only single click events, but fast"],
            ["\"multiclick\"", "Emits single, double and treble presses"] 
          ],
          "default": "multiclick"
        },
        {
          "name": "config/devicemode",
          "refresh.interval": 3000,
          "parse": {
            "at": "0x0009",
            "cl": "0xfcc0",
            "ep": 1,
            "eval": "if (Attr.val == 1) { Item.val = 'compatibility' } else if (Attr.val == 2) { Item.val = 'zigbee' } else { Item.val = 'unknown' }",
            "fn": "zcl:attr",
            "mf": "0x115f"
          },
          "read": {
            "at": "0x0009",
            "cl": "0xfcc0",
            "ep": 1,
            "fn": "zcl:attr",
            "mf": "0x115f"
          },
          "write": {
            "at": "0x0009",
            "cl": "0xfcc0",
            "dt": "0x20",
            "ep": 1,
            "eval": "if (Item.val == 'compatibility') { 1 } else if (Item.val == 'zigbee') { 2 }",
            "fn": "zcl:attr",
            "mf": "0x115f",
            "state.timeout": 2
          },
          "values": [
            ["\"compatibility\"", "Default mode for Xiaomi devices"],
            ["\"zigbee\"", "Closer to zigbee standard"] 
          ],
          "default": "compatibility"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/buttonevent"
        },
        {
          "name": "state/lastupdated"
        }
      ]
    }
  ]
}
Smanar commented 7 months ago
  "manufacturername": "$MF_LUMI",
  "modelid": "lumi.remote.acn003",
  "matchexpr": "R.endpoints.length === 1",

The DDF need to work if the model id is "lumi.remote.acn003", the vendor "LUMI" and if the device have only 1 endpoint. You can remove the line "matchexpr": "R.endpoints.length === 1", To be sure it's not deconz that have issue.

The device need to be reconised, it mean after the inclusion his name go from "0xXXXX" to something readable.

I think this part is ok now, as you are able to see return by websocket.

If you enable log in deconz/help debug view, with flag "info" and "info_l2" you need to see lines like this one [INFO] - No button handler for: %s%s, endpoint: 0x%02X, cluster: %s, command: %s, payload: %s, zclSeq: %u\n", When you use a button.

And we use thoses return to make the button_maps.json file

Idechix commented 7 months ago
  "manufacturername": "$MF_LUMI",
  "modelid": "lumi.remote.acn003",
  "matchexpr": "R.endpoints.length === 1",

The DDF need to work if the model id is "lumi.remote.acn003", the vendor "LUMI" and if the device have only 1 endpoint. You can remove the line "matchexpr": "R.endpoints.length === 1", To be sure it's not deconz that have issue.

The device need to be reconised, it mean after the inclusion his name go from "0xXXXX" to something readable.

I think this part is ok now, as you are able to see return by websocket.

Yes, the device is recognized correctly.

If you enable log in deconz/help debug view, with flag "info" and "info_l2" you need to see lines like this one [INFO] - No button handler for: %s%s, endpoint: 0x%02X, cluster: %s, command: %s, payload: %s, zclSeq: %u\n", When you use a button.

And we use thoses return to make the button_maps.json file

There are no lines like that in the debug view when I press the button. (I tried with and without the button_maps.json modification you suggested earlier)

Smanar commented 7 months ago

Edited; Have take a look on z2m, they don't use bind on 0x0006.

But they are making a request at start await device.getEndpoint(1).write('manuSpecificLumi', {0x0125: {value: 0x02, type: 0x20}}, {manufacturerCode: manufacturerCode});

Cluster FCC0, attribute 0x0125.

Idechix commented 7 months ago

Where should I insert that command? (I'm not home tonight, so I'll try that tomorrow...)

Smanar commented 7 months ago

In fact it's just the "config/clickmode", the DDF need to set the mode at "multiclick" perhaps this request have failed ?

Idechix commented 7 months ago

Should it be set in deCONZ via the DDF file, or externally with a request?

Smanar commented 7 months ago

Externally with a request, using the API. The DDF need to make the request itself, perhaps a problem here.

Else an easier thing to try, set a bind from the device to the coordinator on the cluster 0x0012, this can be done using Deconz https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2077#issuecomment-554640916

If all of that doesn't work, I m out of idea ....

Idechix commented 7 months ago

Nothing worked...

I think values aren't correctly read from device: swversion, config/battery and config/devicemode are generally reported as none (or 0). config/clickmode gives me a readable result, but it is sometimes 'highspeed', sometimes 'multiclick'...