Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 27 forks source link

Xiaomi Aqara Cube rotationcode #68

Closed kispalsz closed 3 years ago

kispalsz commented 3 years ago

I use raspbery Pi 3b+ with Conbee2 USB stick. In the Phoscon-GW app, I see the direction of rotating the Xiaimi cube. Where from where I rotate the control cube. Rotation Code 4002 , this means rotate from side 4 to side 2.

Related domoticz forum post

The Domoticz-deCONZ plugin work for me, but only send rotation event not the real buttoncode as event. I see in log od domoticz(debug) this:

Pushing 'ReadEvent' on to queue 2020-08-04 23:40:12.306 (deCONZ-Zigbee) Processing 'ReadEvent' message 2020-08-04 23:40:12.306 (deCONZ-Zigbee) Received 181 bytes of data 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 81 7e 00 b1 7b 22 65 22 3a 22 63 68 61 6e 67 65 64 22 2c 22 �.ѻ"e":"changed"," 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 69 64 22 3a 22 32 30 22 2c 22 72 22 3a 22 73 65 6e 73 6f 72 id":"20","r":"sensor 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 73 22 2c 22 73 74 61 74 65 22 3a 7b 22 62 75 74 74 6f 6e 65 s","state":{"buttone 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 76 65 6e 74 22 3a 34 30 30 32 2c 22 67 65 73 74 75 72 65 22 vent":4002,"gesture" 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 3a 33 2c 22 6c 61 73 74 75 70 64 61 74 65 64 22 3a 22 32 30 :3,"lastupdated":"20 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 32 30 2d 30 38 2d 30 34 54 32 31 3a 34 30 3a 31 32 2e 32 39 20-08-04T21:40:12.29 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 36 22 7d 2c 22 74 22 3a 22 65 76 65 6e 74 22 2c 22 75 6e 69 6"},"t":"event","uni 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 71 75 65 69 64 22 3a 22 30 30 3a 31 35 3a 38 64 3a 30 30 3a queid":"00:15:8d:00: 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 30 34 3a 32 66 3a 31 66 3a 39 66 2d 30 32 2d 30 30 31 32 22 04:2f:1f:9f-02-0012" 2020-08-04 23:40:12.307 (deCONZ-Zigbee) 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. } 2020-08-04 23:40:12.307 (deCONZ-Zigbee) Pushing 'onMessageCallback' on to queue 2020-08-04 23:40:12.307 (deCONZ-Zigbee) Processing 'onMessageCallback' message 2020-08-04 23:40:12.308 (deCONZ-Zigbee) Calling message handler 'onMessage'. 2020-08-04 23:40:12.308 (deCONZ-Zigbee) onMessage called 2020-08-04 23:40:12.308 (deCONZ-Zigbee) ### WebSocket Data : {'e': 'changed', 'id': '20', 'r': 'sensors', 'state': {'buttonevent': 4002, 'gesture': 3, 'lastupdated': '2020-08-04T21:40:12.296'}, 't': 'event', 'uniqueid': '00:15:8d:00:04:2f:1f:9f-02-0012'} 2020-08-04 23:40:12.309 (deCONZ-Zigbee) ### Update device (deCONZ-Zigbee - lumi.sensor_cube.aqgl01 20) : {'nValue': 40, 'sValue': '40'} 2020-08-04 23:40:12.310 (deCONZ-Zigbee - lumi.sensor_cube.aqgl01 20) Updating device from 0:'Off' to have values 40:'40'. 2020-08-04 23:40:12.850 (deCONZ-Zigbee) Pushing 'onCommandCallback' on to queue 2020-08-04 23:40:12.852 (deCONZ-Zigbee) Processing 'onCommandCallback' message 2020-08-04 23:40:12.852 (deCONZ-Zigbee) Calling message handler 'onCommand'. 2020-08-04 23:40:12.852 (deCONZ-Zigbee) onCommand called for Unit 18: Parameter 'Set Level', Level: 100, Hue: 2020-08-04 23:40:12.853 (deCONZ-Zigbee) Send Command /api/C94AB24840/lights/5/state with {'on': True, 'bri': 254} (0 in buffer) 2020-08-04 23:40:12.853 (deCONZ-Zigbee) Making Request : http://127.0.0.1:8088/api/C94AB24840/lights/5/state with params {'on': True, 'bri': 254} 2020-08-04 23:40:12.876 (deCONZ-Zigbee) Request Return : [{"success":{"/lights/5/state/on":true}},{"success":{"/lights/5/state/bri":254}}] 2020-08-04 23:40:12.877 (deCONZ-Zigbee) Classic Data : [{'success': {'/lights/5/state/on': True}}, {'success': {'/lights/5/state/bri': 254}}] 2020-08-04 23:40:12.447 Status: dzVents: Debug: Dumping domoticz data to /home/pi/domoticz/scripts/dzVents/domoticzData.lua 2020-08-04 23:40:12.713 Status: dzVents: Debug: Processing device-adapter for deCONZ-Zigbee - lumi.sensor_cube.aqgl01 20: Switch device adapter 2020-08-04 23:40:12.715 Status: dzVents: Debug: dzVents version: 3.0.2 2020-08-04 23:40:12.715 Status: dzVents: Debug: Event triggers: 2020-08-04 23:40:12.715 Status: dzVents: Debug: - Device: deCONZ-Zigbee - lumi.sensor_cube.aqgl01 20 2020-08-04 23:40:12.819 Status: dzVents: Info: Handling events for: "deCONZ-Zigbee - lumi.sensor_cube.aqgl01 20", value: "90°"

Is it possible to create a third sub-device in addition to the selector (Shak,Wake,Drop,90,180,Push,Tap) and analog rotation display ( degree), which sends the status code (buttonevent) to the domoticz event system?

Smanar commented 3 years ago

Use 2 widgets is complicated because plugin reconize device using UniqueID in domoticz, so for that you need have 2 widgets with the same UniqueID, possible but need to use hack. Easier solution, I can put a Setting "Custom setting" in hardware plugin, to set ALL your cube widget (the first one, not the rotation one) as text widget or custom widget, like this you can do all you want with values ?

I think I will use text widget, because the custom one make a log every 5 mn even there is no action.

kispalsz commented 3 years ago

I had a little hard time understanding what you wrote to me. Do I still need to give you feedback? Can I help with (implementation), testing?

Of course, it would be good if not only the rotation code, but all the code appeared in domoticz on a device that dzVents can already handle. But keep both the selector (if someone doesn’t want to use complicated codes) and the analog rotation meter as well. (This (analog rotation meter) is very useful, for example, for volume and brightness adjustment.

Smanar commented 3 years ago

I have just see the post on domoticz https://www.domoticz.com/forum/viewtopic.php?f=59&t=33581&p=253899&hilit=deconz#p253899

I m trying the warren tips, If it works it will be the better solution.

On my previous idea, the "analog rotation meter" will stay, but the user can choose beetween the selector or a widget with raw value for the second device.

Smanar commented 3 years ago

Ok, so I have done a modification on beta code, I m using the @warren solution.

So nothing change on the code, just now you can retreive the complete value using method on the domoticz forum gived by him.

kispalsz commented 3 years ago

Thanks. It works. I see all 4 character codes, the selector also works as well as the analog rotation. So the cube became very valuable :)

Thanks.

Smanar commented 3 years ago

You can thx waarren ^^, I realy don't know this working mode.