PiZiGate and Aqara wireless switch

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

pipiche
Posts: 2009
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: PiZiGate and Aqara wireless switch

Post by pipiche »

@ronaldbro the plugin is just reacting to what the device is sending
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: PiZiGate and Aqara wireless switch

Post by ronaldbro »

@pipiche, I understand that that's the goal, but there's always an interpretation of the messages ;)

I did some more research and I found the missing event.

this is the single click:
Spoiler: show
2019-04-01 21:32:28.074 (Zigate) ZigateRead - decoded data : 018102000f790500ef01001200550021000200017b03 lenght : 44
2019-04-01 21:32:28.074 (Zigate) ZigateRead - MsgType: 8102, MsgLength: 000f, MsgCRC: 79, Data: 0500ef0100120055002100020001; RSSI: 7b
2019-04-01 21:32:28.074 (Zigate) ZigateRead - MsgType 8102 - Report Individual Attribute response : 018102000f790500ef01001200550021000200017b03
2019-04-01 21:32:28.074 (Zigate) Decode8102 - Individual Attribute response : [00ef:01] ClusterID: 0012 AttributeID: 0055 Status: 00 Type: 21 Size: 0002 ClusterData: >0001<
2019-04-01 21:32:28.074 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:32:28.074 (Zigate) Decode8102 : Attribute Report from 00ef SQN = 05 ClusterID = 0012 AttrID = 0055 Attribute Data = 0001
2019-04-01 21:32:28.075 (Zigate) Touch unit Zigate - SwitchAQ2-00158d00021311e6-01 nwkid: 00ef
2019-04-01 21:32:28.077 (Zigate) Device : 00ef MacCapa : 80 updating SQN to 05
2019-04-01 21:32:28.077 (Zigate) updSQN - Device : 00ef updating SQN to 05
2019-04-01 21:32:28.077 (Zigate) ReadCluster - MsgData lenght is: 28 out of 24+
2019-04-01 21:32:28.078 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:32:28.078 (Zigate) ReadCluster - 0012 NwkId: 00ef Ep: 01 AttrId: 0055 AttyType: 21 Attsize: 0002 Status: 00 AttrValue: 0001
2019-04-01 21:32:28.078 (Zigate) decodeAttribute( 21, 0001)
2019-04-01 21:32:28.078 (Zigate) ReadCluster - ClusterId=0012 - Switch Aqara: EP: 01 Value: 1
2019-04-01 21:32:28.078 (Zigate) MajDomoDevice - Device ID : 00158d00021311e6 - Device EP : 01 - Type : 0006 - Value : 1 - Hue : - Attribute_ :
2019-04-01 21:32:28.078 (Zigate) ClusterSearch - Cluster: 0006, ProfileID: , ZDeviceID: , create: False
2019-04-01 21:32:28.078 (Zigate) MajDomoDevice - Type = Switch
2019-04-01 21:32:28.079 (Zigate) MajDomoDevice - NWKID = 00ef IEEE = 00158d00021311e6 Unit = 269
2019-04-01 21:32:28.079 (Zigate) MajDomoDevice - {'0012': {}, '0000': {}, 'ClusterType': {'269': 'SwitchAQ2'}, '0006': {}}
2019-04-01 21:32:28.079 (Zigate) MajDomoDevice - We have 1 EPs with ClusterType
2019-04-01 21:32:28.079 (Zigate) MajDomoDevice - NWKID: 00ef SwitchType: 18, DeviceType: SwitchAQ2, ClusterType: Switch, old_nVal: 3 , old_sVal: 20
2019-04-01 21:32:28.079 (Zigate) UpdateDevice_v2 for : 62 Battery Level = 90 Signal Level = 123
2019-04-01 21:32:28.079 (Zigate) UpdateDevice_v2 for : 62 RSSI = 6
2019-04-01 21:32:28.079 (Zigate) UpdateDevice - (Zigate - SwitchAQ2-00158d00021311e6-01) 1:00
2019-04-01 21:32:28.080 (Zigate) Update Values 1:'00:' (Zigate - SwitchAQ2-00158d00021311e6-01)
2019-04-01 21:32:28.080 (Zigate - SwitchAQ2-00158d00021311e6-01) Updating device from 3:'20' to have values 1:'00'.
2019-04-01 21:32:29.838 (Zigate) onHeartbeat - busy = False
this is the double click:
Spoiler: show
1 bytes of data
2019-04-01 21:33:05.125 (Zigate) 84 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2019-04-01 21:33:05.125 (Zigate) Received 1 bytes of data
2019-04-01 21:33:05.125 (Zigate) 03 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .
2019-04-01 21:33:05.127 (Zigate) ZigateRead - decoded data : 018102000f860600ef01001200550021000200028403 lenght : 44
2019-04-01 21:33:05.127 (Zigate) ZigateRead - MsgType: 8102, MsgLength: 000f, MsgCRC: 86, Data: 0600ef0100120055002100020002; RSSI: 84
2019-04-01 21:33:05.127 (Zigate) ZigateRead - MsgType 8102 - Report Individual Attribute response : 018102000f860600ef01001200550021000200028403
2019-04-01 21:33:05.127 (Zigate) Decode8102 - Individual Attribute response : [00ef:01] ClusterID: 0012 AttributeID: 0055 Status: 00 Type: 21 Size: 0002 ClusterData: >0002<
2019-04-01 21:33:05.127 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:33:05.127 (Zigate) Decode8102 : Attribute Report from 00ef SQN = 06 ClusterID = 0012 AttrID = 0055 Attribute Data = 0002
2019-04-01 21:33:05.127 (Zigate) Too early for a new update of LastSeen 00ef
2019-04-01 21:33:05.128 (Zigate) Device : 00ef MacCapa : 80 updating SQN to 06
2019-04-01 21:33:05.128 (Zigate) updSQN - Device : 00ef updating SQN to 06
2019-04-01 21:33:05.128 (Zigate) ReadCluster - MsgData lenght is: 28 out of 24+
2019-04-01 21:33:05.128 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:33:05.128 (Zigate) ReadCluster - 0012 NwkId: 00ef Ep: 01 AttrId: 0055 AttyType: 21 Attsize: 0002 Status: 00 AttrValue: 0002
2019-04-01 21:33:05.128 (Zigate) decodeAttribute( 21, 0002)
2019-04-01 21:33:05.128 (Zigate) ReadCluster - ClusterId=0012 - Switch Aqara: EP: 01 Value: 2
2019-04-01 21:33:05.128 (Zigate) MajDomoDevice - Device ID : 00158d00021311e6 - Device EP : 01 - Type : 0006 - Value : 2 - Hue : - Attribute_ :
2019-04-01 21:33:05.128 (Zigate) ClusterSearch - Cluster: 0006, ProfileID: , ZDeviceID: , create: False
2019-04-01 21:33:05.128 (Zigate) MajDomoDevice - Type = Switch
2019-04-01 21:33:05.128 (Zigate) MajDomoDevice - NWKID = 00ef IEEE = 00158d00021311e6 Unit = 269
2019-04-01 21:33:05.128 (Zigate) MajDomoDevice - {'0012': {}, '0000': {}, 'ClusterType': {'269': 'SwitchAQ2'}, '0006': {}}
2019-04-01 21:33:05.128 (Zigate) MajDomoDevice - We have 1 EPs with ClusterType
2019-04-01 21:33:05.129 (Zigate) MajDomoDevice - NWKID: 00ef SwitchType: 18, DeviceType: SwitchAQ2, ClusterType: Switch, old_nVal: 1 , old_sVal: 00
2019-04-01 21:33:05.129 (Zigate) UpdateDevice_v2 for : 62 Battery Level = 90 Signal Level = 132
2019-04-01 21:33:05.129 (Zigate) UpdateDevice_v2 for : 62 RSSI = 6
2019-04-01 21:33:05.129 (Zigate) UpdateDevice - (Zigate - SwitchAQ2-00158d00021311e6-01) 2:10
2019-04-01 21:33:05.129 (Zigate) Update Values 2:'10:' (Zigate - SwitchAQ2-00158d00021311e6-01)
2019-04-01 21:33:05.129 (Zigate - SwitchAQ2-00158d00021311e6-01) Updating device from 1:'00' to have values 2:'10'.
Long press:
Spoiler: show
2019-04-01 21:33:39.979 (Zigate) ZigateRead - decoded data : 018102000f6d0700ef01001200550021000200006c03 lenght : 44
2019-04-01 21:33:39.979 (Zigate) ZigateRead - MsgType: 8102, MsgLength: 000f, MsgCRC: 6d, Data: 0700ef0100120055002100020000; RSSI: 6c
2019-04-01 21:33:39.979 (Zigate) ZigateRead - MsgType 8102 - Report Individual Attribute response : 018102000f6d0700ef01001200550021000200006c03
2019-04-01 21:33:39.979 (Zigate) Decode8102 - Individual Attribute response : [00ef:01] ClusterID: 0012 AttributeID: 0055 Status: 00 Type: 21 Size: 0002 ClusterData: >0000<
2019-04-01 21:33:39.980 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:33:39.980 (Zigate) Decode8102 : Attribute Report from 00ef SQN = 07 ClusterID = 0012 AttrID = 0055 Attribute Data = 0000
2019-04-01 21:33:39.980 (Zigate) Too early for a new update of LastSeen 00ef
2019-04-01 21:33:39.980 (Zigate) Device : 00ef MacCapa : 80 updating SQN to 07
2019-04-01 21:33:39.980 (Zigate) updSQN - Device : 00ef updating SQN to 07
2019-04-01 21:33:39.981 (Zigate) ReadCluster - MsgData lenght is: 28 out of 24+
2019-04-01 21:33:39.981 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:33:39.981 (Zigate) ReadCluster - 0012 NwkId: 00ef Ep: 01 AttrId: 0055 AttyType: 21 Attsize: 0002 Status: 00 AttrValue: 0000
2019-04-01 21:33:39.981 (Zigate) decodeAttribute( 21, 0000)
2019-04-01 21:33:39.981 (Zigate) ReadCluster - ClusterId=0012 - Switch Aqara: EP: 01 Value: 0
2019-04-01 21:33:39.981 (Zigate) MajDomoDevice - Device ID : 00158d00021311e6 - Device EP : 01 - Type : 0006 - Value : 3 - Hue : - Attribute_ :
2019-04-01 21:33:39.981 (Zigate) ClusterSearch - Cluster: 0006, ProfileID: , ZDeviceID: , create: False
2019-04-01 21:33:39.981 (Zigate) MajDomoDevice - Type = Switch
2019-04-01 21:33:39.982 (Zigate) MajDomoDevice - NWKID = 00ef IEEE = 00158d00021311e6 Unit = 269
2019-04-01 21:33:39.982 (Zigate) MajDomoDevice - {'0012': {}, '0000': {}, 'ClusterType': {'269': 'SwitchAQ2'}, '0006': {}}
2019-04-01 21:33:39.982 (Zigate) MajDomoDevice - We have 1 EPs with ClusterType
2019-04-01 21:33:39.982 (Zigate) MajDomoDevice - NWKID: 00ef SwitchType: 18, DeviceType: SwitchAQ2, ClusterType: Switch, old_nVal: 2 , old_sVal: 10
2019-04-01 21:33:39.982 (Zigate) UpdateDevice_v2 for : 62 Battery Level = 90 Signal Level = 108
2019-04-01 21:33:39.982 (Zigate) UpdateDevice_v2 for : 62 RSSI = 5
2019-04-01 21:33:39.983 (Zigate) UpdateDevice - (Zigate - SwitchAQ2-00158d00021311e6-01) 3:20
2019-04-01 21:33:39.983 (Zigate) Update Values 3:'20:' (Zigate - SwitchAQ2-00158d00021311e6-01)
2019-04-01 21:33:39.983 (Zigate - SwitchAQ2-00158d00021311e6-01) Updating device from 2:'10' to have values 3:'20'.
long press release:
Spoiler: show
2019-04-01 21:40:44.909 (Zigate) ZigateRead - decoded data : 018102000f700d00ef01001200550021000200ff8403 lenght : 44
2019-04-01 21:40:44.910 (Zigate) ZigateRead - MsgType: 8102, MsgLength: 000f, MsgCRC: 70, Data: 0d00ef01001200550021000200ff; RSSI: 84
2019-04-01 21:40:44.910 (Zigate) ZigateRead - MsgType 8102 - Report Individual Attribute response : 018102000f700d00ef01001200550021000200ff8403
2019-04-01 21:40:44.910 (Zigate) Decode8102 - Individual Attribute response : [00ef:01] ClusterID: 0012 AttributeID: 0055 Status: 00 Type: 21 Size: 0002 ClusterData: >00ff<
2019-04-01 21:40:44.910 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:40:44.910 (Zigate) Decode8102 : Attribute Report from 00ef SQN = 0d ClusterID = 0012 AttrID = 0055 Attribute Data = 00ff
2019-04-01 21:40:44.910 (Zigate) Too early for a new update of LastSeen 00ef
2019-04-01 21:40:44.911 (Zigate) Device : 00ef MacCapa : 80 updating SQN to 0d
2019-04-01 21:40:44.911 (Zigate) updSQN - Device : 00ef updating SQN to 0d
2019-04-01 21:40:44.911 (Zigate) ReadCluster - MsgData lenght is: 28 out of 24+
2019-04-01 21:40:44.911 (Zigate) DeviceExist - Found in ListOfDevices with status = inDB
2019-04-01 21:40:44.911 (Zigate) ReadCluster - 0012 NwkId: 00ef Ep: 01 AttrId: 0055 AttyType: 21 Attsize: 0002 Status: 00 AttrValue: 00ff
2019-04-01 21:40:44.912 (Zigate) decodeAttribute( 21, 00ff)
2019-04-01 21:40:44.912 (Zigate) ReadCluster - ClusterId=0012 - Switch Aqara: EP: 01 Value: 255
2019-04-01 21:40:44.912 (Zigate) MajDomoDevice - Device ID : 00158d00021311e6 - Device EP : 01 - Type : 0006 - Value : 255 - Hue : - Attribute_ :
2019-04-01 21:40:44.912 (Zigate) ClusterSearch - Cluster: 0006, ProfileID: , ZDeviceID: , create: False
2019-04-01 21:40:44.912 (Zigate) MajDomoDevice - Type = Switch
2019-04-01 21:40:44.912 (Zigate) MajDomoDevice - NWKID = 00ef IEEE = 00158d00021311e6 Unit = 269
2019-04-01 21:40:44.913 (Zigate) MajDomoDevice - {'0012': {}, '0000': {}, 'ClusterType': {'269': 'SwitchAQ2'}, '0006': {}}
2019-04-01 21:40:44.913 (Zigate) MajDomoDevice - We have 1 EPs with ClusterType
2019-04-01 21:40:44.913 (Zigate) MajDomoDevice - NWKID: 00ef SwitchType: 18, DeviceType: SwitchAQ2, ClusterType: Switch, old_nVal: 3 , old_sVal: 20
2019-04-01 21:40:45.564 (Zigate) onHeartbeat - busy = False
The last one is not processed and is missing the update values.

ClusterData 0001 --> single press
ClusterData 0002 --> double click
ClusterData 0000 --> long press
ClusterData 00ff --> long press release

I tried it many times and it's always the same.

Sometimes the long press release is followed by a single click. This might be a hardware issue that an accidental click is detected when releasing the button. I expect that Xiaomi discards a single click when it's too close after another event in their gateway.

Hope this helps.
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: PiZiGate and Aqara wireless switch

Post by ronaldbro »

I was looking in the code and found the following:

Modules/Domoticz.py line 918-924

Code: Select all

elif DeviceType == "SwitchAQ2":  # multi lvl switch
                    value = int(value)
                    if value == 1: state = "00"
                    elif value == 2: state = "10"
                    elif value == 3: state = "20"
                    elif value == 4: state = "30"
                    else:
When I change this to

Code: Select all

elif DeviceType == "SwitchAQ2":  # multi lvl switch
                    value = int(value)
                    if value == 1: state = "00"
                    elif value == 2: state = "10"
                    elif value == 3: state = "20"
                    elif value == 255: state = "30"
                    else:
Then I receive the 'long press release' event.
pipiche
Posts: 2009
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: PiZiGate and Aqara wireless switch

Post by pipiche »

I suggest you submit a Pull Request on the plugin GitHub
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: PiZiGate and Aqara wireless switch

Post by ronaldbro »

just did. Thanks for your help.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest