Edge Driver for Aqara Cube

Greetings once again!

I had some issues with pairing my devices last week, a lot of dropouts, re-pairing … but now it seems stable for 3 days in a row, hopefully my troubles are over.

I have a few questions regarding the cube. I’m used to using the standard gestures DTH (flip90/180, tap/kock, slide, shake, rotate left/right) and advanced DTH with recognition of side.

I see your driver is a bit different. It recognizes tap/knock, slide and shake.
Rotation/left right is improved, direction can be determined by sign +/- and the amount of rotation
Rotation affects the dimmer in %, which can be used for lights control, great! What are increments?
Switch enables/disables change in % value of dimmer
Flipping is providing info on which side the cube is on (as with advanced DTH)

Flip90/180 is detected as well, can see it clearly in the log now … this could be even better if possible to detect what kind of flip90 did occur … instead of flip90, it might be possible to detect 4 distinct flips, flip left/right/front/back … this is also possible to achieve by implementing a matrix in a following way:

Flip left := (face=left AND face_prev=up) OR
(face=down AND face_prev=left) OR
(face=right AND face_prev=down) OR
(face=up AND face_prev=right)

… and the simalar logic goes for other 3 potential flips!
This is something that could be implemented in WebCore (until it lasts) or maybe Sharptools (free?) but this might be something you could consider to implement in driver?

Motion detection: this is something I’m a bit unsure of how it works. Once you touch the cube it is detected, after a few (5-10?) seconds, it is off, and after activation there is some blocking of another activation for 1 minutes or so? I see the motion is detected regarding of the actual Action, together with flip for example … so it can’t be used independently.

I can see Action: Ready on initiating a gesture. What is the logic here, I see it frequently popping up after motion detection goes off. but sometimes independantly, I guess the detection blocking timer is shorter here … actually seems like there’s no timer, Action Ready is after any movement, correct?

Maybe you already have some mini manual or description that answers my questions? Couldn’t find much, except some of your inquiries regarding the cube in the developer forum.

Much appriciated! :slight_smile:

@JDRoberts
can you please move the last message to another topic as it’s about the cube. and there are many questions part of them I don’t fully understand

I’m sorry, you’ll need to ask a moderator to split the topic. Maybe @nayelyz has time if she’s not too busy?

I suggest the title of “Edge Driver for Aqara Cube?”

1 Like

But wait, are you the author of the cube driver? If not, could you point me in the right direction?

Sure, I can do that, and ask some straight questions

2 Likes

Just remembered that I actually do have a specific question regarding the switch, relevant to this topic :wink:

I see there were some reports that drivers are not working, but that was fixed in the meantime.

So I have a Model WXKG11LM and using your driver.

Single/double press and hold works fine, but I can’t get Press 3/4/5 times to work.

Tried with very rapid presses, tried with slower … nothing seems to work:

Am I doing something wrong or press 3/4/5 times doesn’t work for this model?

You mean logs from ST app? If I remember correctly, nothing was logged on 3/4/5 presses.

I agree about the number of presses, IMO 3 is still totally fine, 4 is maybe a press too much, and 5 is madness.

My kids are sleeping and the button is in the room (it’s for room light controls) so I can get you the logs tomorrow. Just tell me which ones, from ST app or something else

What is best approach for long-term Edge CLI logging to file??

1 Like

I associated action for each of the presses/holds
Here are some logs from CLI (just installed it and first time used :slight_smile: )

Every 30s on idle:

2022-11-16T07:54:15.420727633+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 driver device thread event handled

On single press:
Action/event execution as selected

2022-11-16T07:57:56.159586274+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Received event with handler zigbee
2022-11-16T07:57:56.248535274+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x11CE, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: 0x0012 >, lqi: 0xD2, rssi: -58, body_length: 0x0008, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x18, seqno: 0x63, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0055, DataType: Uint16, Uint16: 0x0001 > > > >
2022-11-16T07:57:56.421000274+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Found ZigbeeMessageDispatcher handler in switch
2022-11-16T07:57:56.447270608+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 Executing ZclClusterAttributeValueHandler: cluster: 0x0012, attribute: 0x0055
2022-11-16T07:57:56.459006274+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> emitting event: {“attribute_id”:“button”,“capability_id”:“button”,“component_id”:“main”,“state”:{“value”:“pushed”},“state_change”:true}
2022-11-16T07:57:56.566475941+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 WXKG11LM device thread event handled

On hold (and release after ca 2s):
Action/event execution as selected

2022-11-16T08:00:49.174980585+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Received event with handler zigbee
2022-11-16T08:00:49.185556251+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x11CE, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: 0x0012 >, lqi: 0xCC, rssi: -70, body_length: 0x0008, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x18, seqno: 0x65, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0055, DataType: Uint16, Uint16: 0x0000 > > > >
2022-11-16T08:00:49.257588585+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Found ZigbeeMessageDispatcher handler in switch
2022-11-16T08:00:49.262933918+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 Executing ZclClusterAttributeValueHandler: cluster: 0x0012, attribute: 0x0055
2022-11-16T08:00:49.270469585+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> emitting event: {“attribute_id”:“button”,“capability_id”:“button”,“component_id”:“main”,“state”:{“value”:“held”},“state_change”:true}
2022-11-16T08:00:49.307994918+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 WXKG11LM device thread event handled
2022-11-16T08:00:49.566391918+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Received event with handler zigbee
2022-11-16T08:00:49.616010252+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x11CE, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: 0x0012 >, lqi: 0xD0, rssi: -70, body_length: 0x0008, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x18, seqno: 0x66, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0055, DataType: Uint16, Uint16: 0x00FF > > > >
2022-11-16T08:00:49.637934918+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Found ZigbeeMessageDispatcher handler in switch
2022-11-16T08:00:49.643577918+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 Executing ZclClusterAttributeValueHandler: cluster: 0x0012, attribute: 0x0055
2022-11-16T08:00:49.655070252+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 button released, no such st event
2022-11-16T08:00:49.662593585+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 WXKG11LM device thread event handled

On double press:
Action/event execution as selected

2022-11-16T08:05:19.811020975+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Received event with handler zigbee
2022-11-16T08:05:19.821432975+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x11CE, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: 0x0012 >, lqi: 0xCE, rssi: -62, body_length: 0x0008, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x18, seqno: 0x6D, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0055, DataType: Uint16, Uint16: 0x0002 > > > >
2022-11-16T08:05:19.862697975+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Found ZigbeeMessageDispatcher handler in switch
2022-11-16T08:05:19.871850308+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 Executing ZclClusterAttributeValueHandler: cluster: 0x0012, attribute: 0x0055
2022-11-16T08:05:19.883842975+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> emitting event: {“attribute_id”:“button”,“capability_id”:“button”,“component_id”:“main”,“state”:{“value”:“pushed_2x”},“state_change”:true}
2022-11-16T08:05:19.929023641+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 WXKG11LM device thread event handled

On 3x & 4x press:
No log update and no execution of selected action/event
Tried multiple times … rapid, slower … nada!

On 5x press (rapid or slower):
Log update but no execution of selected or any other action/event … interesting, there is life!

2022-11-16T08:10:51.479613586+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Received event with handler zigbee
2022-11-16T08:10:51.490858872+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> received Zigbee message: < ZigbeeMessageRx || type: 0x00, < AddressHeader || src_addr: 0x11CE, src_endpoint: 0x01, dest_addr: 0x0000, dest_endpoint: 0x01, profile: 0x0104, cluster: Basic >, lqi: 0xD2, rssi: -68, body_length: 0x003A, < ZCLMessageBody || < ZCLHeader || frame_ctrl: 0x1C, mfg_code: 0x115F, seqno: 0x71, ZCLCommandId: 0x0A >, < ReportAttribute || < AttributeRecord || AttributeId: 0x0005, DataType: CharString, ModelIdentifier: “lumi.remote.b1acn01” >, < AttributeRecord || AttributeId: 0xFF01, DataType: CharString, CharString: “\x01\x21\xD1\x0B\x03\x28\x1C\x04\x21\xA8\x13\x05\x21\xF9\x00\x06\x24\x0A\x00\x00\x00\x00\x0A\x21\x00\x00” > > > >
2022-11-16T08:10:51.508219215+00:00 TRACE Xiaomi/Aqara Switch and Button v1.7 Found ZigbeeMessageDispatcher handler in switch
2022-11-16T08:10:51.514024783+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 Executing ZclClusterAttributeValueHandler: cluster: Basic, attribute: 0xFF01
2022-11-16T08:10:51.523838020+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 <ZigbeeDevice: da9f2bf2-91f5-426c-8813-0293c9ddf33a [0x11CE] (Knapp)> emitting event: {“attribute_id”:“battery”,“capability_id”:“battery”,“component_id”:“main”,“state”:{“value”:100}}
2022-11-16T08:10:51.546750804+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 0x04 Uint16: 0x13A8
2022-11-16T08:10:51.599678922+00:00 INFO Xiaomi/Aqara Switch and Button v1.7 xiaomi_utils.lua: emit_signal_event 249 10
2022-11-16T08:10:51.623889688+00:00 DEBUG Xiaomi/Aqara Switch and Button v1.7 WXKG11LM device thread event handled

Well, that’s it then, all clear, no possible!

But thanks for making me look into CLI, not scary at all, as some imply :slight_smile:

But what is it that I’m getting on 5x press, according to log? Something is being logged