Frans-Willem / AqaraHub

AqaraHub is an open-source Zigbee hub for Xiaomi Aqara devices. It aims to be a replacement to the Xiaomi Gateway that does not require communication to outside servers, and uses a saner communication option (e.g. MQTT).
252 stars 34 forks source link

Aqara SP-EUC01 isn't support. #59

Open itgb opened 4 years ago

itgb commented 4 years ago

hello, I have test SP-EUC01 with AquaraHub, and it can't be support. I did some research in Aqaurahub and i found that there some key ZDO commands aren't implement, such as TC_DEV_IND、NODE_DESC_RSP、ACTIVE_EP_RSP and so on. unfortunately these commands are key to support standard zigbee device. Mostly Aqara Device isn't standard ,but SP-EUC01.

Frans-Willem commented 4 years ago

Were you unable to get it to connect to the network due to these missing commands ? Or does the device pair, but otherwise doesn't respond to commands or doesn't send commands ?

All the commands you've listed seem events or things that come from the device to the hub, and shouldn't be hard to respond to from AqaraHub.

Either way, it's an interesting device, so I'll order one to debug with. In the mean time, I'd be happy to look at more debug output and give pointers as to what could be missing from AqaraHub to support this.

Frans-Willem commented 4 years ago

I've attempted to order one of these, but can't find it on my usual channels (aliexpress or banggood). Any idea where I could order one ?

itgb commented 4 years ago

Were you unable to get it to connect to the network due to these missing commands ? Or does the device pair, but otherwise doesn't respond to commands or doesn't send commands ?

All the commands you've listed seem events or things that come from the device to the hub, and shouldn't be hard to respond to from AqaraHub.

Either way, it's an interesting device, so I'll order one to debug with. In the mean time, I'd be happy to look at more debug output and give pointers as to what could be missing from AqaraHub to support this.

Hm, yes, pair failed for missing commands. However, zigbee2mqtt can support it. The following are logs for SP-EUC01(un-supported) and WXKG12LM( supported).

Aqara EU smart plug SP-EUC01: UN-SUPPORT

[FRAME] << AREQ ZDO_TC_DEV_IND 2e 54 c6 60 76 3c df 8c cf 04 00 00 [ZnpApi] Unhandled frame AREQ ZDO_TC_DEV_IND [FRAME] << AREQ ZDO_END_DEVICE_ANNCE_IND 2e 54 2e 54 c6 60 76 3c df 8c cf 04 8e [ZnpApi] Unhandled frame AREQ ZDO_END_DEVICE_ANNCE_IND ZDO_TC_DEV_IND and ZDO_END_DEVICE_ANNCE_IND are standard behaviors for standard zigbee devices. However, Aqarahub don't process the commands. The meaning of the two commands, you can check Aqara wireless switch (with gyroscope) WXKG12LM: **SUPPORT** [FRAME] << AREQ ZDO_TC_DEV_IND 1d 80 93 f6 4c 04 00 8d 15 00 00 00 [ZnpApi] Unhandled frame AREQ ZDO_TC_DEV_IND [FRAME] << AREQ ZDO_END_DEVICE_ANNCE_IND 1d 80 1d 80 93 f6 4c 04 00 8d 15 00 80 [ZnpApi] Unhandled frame AREQ ZDO_END_DEVICE_ANNCE_IND [FRAME] << AREQ AF_INCOMING_MSG 00 00 00 00 1d 80 01 01 00 6e 00 ff 4a 0a 00 00 21 18 00 0a 05 00 42 16 6c 75 6d 69 2e 73 65 6e 73 6f 72 5f 73 77 69 74 63 68 2e 61 71 33 01 00 20 05 1d 80 1d [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP 1d 80 [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP 1d 80 [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 93 f6 4c 04 00 8d 15 00 [PublishValue] Publishing to 'AqaraHub/00158D00044CF693/1/in/Basic/Report Attributes': {"reports":[{"Attribute data":{"type":"string","value":"lumi.sensor_switch.aq3"},"Attribute identifier":"ModelIdentifier"},{"Attribute data":{"type":"uint8","value":5},"Attribute identifier":"ApplicationVersion"}]} [OnZclCommand] Looks like something per-attribute. Publishing per-attribute too [PublishValue] Publishing to 'AqaraHub/00158D00044CF693/1/in/Basic/Report Attributes/ModelIdentifier': {"type":"string","value":"lumi.sensor_switch.aq3"} [PublishValue] Publishing to 'AqaraHub/00158D00044CF693/1/in/Basic/Report Attributes/ApplicationVersion': {"type":"uint8","value":5} [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 93 f6 4c 04 00 8d 15 00 [FRAME] << AREQ AF_INCOMING_MSG 00 00 00 00 1d 80 01 01 00 86 00 8e 56 0a 00 00 2f 1c 5f 11 01 0a 01 ff 42 26 01 21 bd 0b 03 28 1e 04 21 a8 01 05 21 2f 00 06 24 01 00 00 00 00 08 21 05 01 0a 21 00 00 98 21 00 00 99 21 00 00 1d 80 1d [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP 1d 80 [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP 1d 80 [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 93 f6 4c 04 00 8d 15 00 [PublishValue] Publishing to 'AqaraHub/00158D00044CF693/1/in/Basic/Report Attributes': {"reports":[{"Attribute data":{"type":"xiaomi_ff01","value":{"1":{"type":"uint16","value":3005},"10":{"type":"uint16","value":0},"152":{"type":"uint16","value":0},"153":{"type":"uint16","value":0},"3":{"type":"int8","value":30},"4":{"type":"uint16","value":424},"5":{"type":"uint16","value":47},"6":{"type":"uint40","value":1},"8":{"type":"uint16","value":261}}},"Attribute identifier":65281}]} [OnZclCommand] Looks like something per-attribute. Publishing per-attribute too [PublishValue] Publishing to 'AqaraHub/00158D00044CF693/1/in/Basic/Report Attributes/0xFF01': {"type":"xiaomi_ff01","value":{"1":{"type":"uint16","value":3005},"10":{"type":"uint16","value":0},"152":{"type":"uint16","value":0},"153":{"type":"uint16","value":0},"3":{"type":"int8","value":30},"4":{"type":"uint16","value":424},"5":{"type":"uint16","value":47},"6":{"type":"uint40","value":1},"8":{"type":"uint16","value":261}}} [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 93 f6 4c 04 00 8d 15 00
itgb commented 4 years ago

aliexpress

it can be buy from https://aqara.ru/product/aqara-smart-plug/.

itgb commented 4 years ago

I've attempted to order one of these, but can't find it on my usual channels (aliexpress or banggood). Any idea where I could order one ?

I think the smart plug is a completely standard zigbee device. My standard 3rd party zigbeehub can support it. It's strange, mostly aqara devices are non-standard except the smart plug.

Frans-Willem commented 4 years ago

You're right that AqaraHub isn't handling TC_DEV_IND or END_DEVICE_ANNCE_IND, but I don't believe that to be the problem. They're events from the CC2531 stick to AqaraHub indicating that a device was added to the trust-center (security key related stuff), as well as an event indicating a new device joined the network (end device announcement).

I believe Zigbee2mqtt and other hubs will, in response to these messages, interrogate the device to ask what device it is exactly, but AqaraHub isn't really interested as it treats all devices the same, and just waits for Zigbee Cluster Library events/reports coming in.

The fact that you are seeing the TC_DEV and END_DEVICE_ANNCE indicates that the device did in fact join the network correctly, and you should be able to send it commands. You can extract the device ID manually, ignore the first two bytes following the TC_DEV_IND (0x2e, 0x54) then take the following 8 bytes (c6 60 76 3c df 8c cf 04) and put them in the reversed order (this is because it's sent little-endian over the wire) as follows: 04cf8cdf3c7660c6.

Could you (after pairing the device again, and seeing the END_DEVICE_ANNCE) try sending {"command": "On"} or {"command": "Off"} to AqaraHub/04CF8CDF3C7660C6/1/out/OnOff? I believe that should turn it on or off.

itgb commented 4 years ago

You're right that AqaraHub isn't handling TC_DEV_IND or END_DEVICE_ANNCE_IND, but I don't believe that to be the problem. They're events from the CC2531 stick to AqaraHub indicating that a device was added to the trust-center (security key related stuff), as well as an event indicating a new device joined the network (end device announcement).

I believe Zigbee2mqtt and other hubs will, in response to these messages, interrogate the device to ask what device it is exactly, but AqaraHub isn't really interested as it treats all devices the same, and just waits for Zigbee Cluster Library events/reports coming in.

The fact that you are seeing the TC_DEV and END_DEVICE_ANNCE indicates that the device did in fact join the network correctly, and you should be able to send it commands. You can extract the device ID manually, ignore the first two bytes following the TC_DEV_IND (0x2e, 0x54) then take the following 8 bytes (c6 60 76 3c df 8c cf 04) and put them in the reversed order (this is because it's sent little-endian over the wire) as follows: 04cf8cdf3c7660c6.

Could you (after pairing the device again, and seeing the END_DEVICE_ANNCE) try sending {"command": "On"} or {"command": "Off"} to AqaraHub/04CF8CDF3C7660C6/1/out/OnOff? I believe that should turn it on or off.

thanks a lot. It's working now. Sending a report cmd to the device, will get response. I send the cmd:"AqaraHub/04cf8cdf3c7660c6/1/out/Basic/Read Attributes" -m '{"attributes":[5]}' , and get mode [SP-EUC01].

itgb commented 4 years ago

hello,I want to support the smart plug with following steps: 1.Aqarahub: when receive END_DEVICE_ANNCE, extract the Device ID automatically ,and, push the Device ID to a external controller by mqtt;

  1. external controller: when receive a new Device ID, send a [Read Attributes "ModelIdentifier"] request to Aqarahub; 3.Aqarahub: will receive a [Read Attributes Response], and then, push it to external controller by mqtt; of course, this step is supported now in Aqarahub. I think the external controller can be builtin with Aqarahub , in this way, Aqarahub can support all aqara devices . In short , if Aqarahub can process END_DEVICE_ANNCE and trigger a [Read Attributes "ModelIdentifier"] request, it will be nice.
Frans-Willem commented 4 years ago

Could you check if pull request #62 or branch feature/inform-device-join works for you and fixes your issue ?

I'm publishing the information to the log and MQTT, but I'm not implementing any behaviour (e.g. reading certain attributes) on joined devices, as these kind of investigate-devices-on-join routines usually fail on battery powered devices.

itgb commented 4 years ago

Could you check if pull request #62 or branch feature/inform-device-join works for you and fixes your issue ?

I'm publishing the information to the log and MQTT, but I'm not implementing any behaviour (e.g. reading certain attributes) on joined devices, as these kind of investigate-devices-on-join routines usually fail on battery powered devices.

wonderful, I will check it tomorrow.

itgb commented 4 years ago

Could you check if pull request #62 or branch feature/inform-device-join works for you and fixes your issue ?

I'm publishing the information to the log and MQTT, but I'm not implementing any behaviour (e.g. reading certain attributes) on joined devices, as these kind of investigate-devices-on-join routines usually fail on battery powered devices.

it works now. thanks.

DuanYuXian commented 4 years ago

Hello sir, I tested several devices with AqaraHub, such as smar plug (SP-EUC01), Rubik's cube controller and mini switch. The Rubik's cube controller and mini switch can join normally, but after joining the network with smart plug, it will cause a few exceptions:

  1. After the smart plug (SP-EUC01) is added, the original network access time is 60s, but it will become longer. After about 3-4 minutes, the log will show that the network access time is over.
  2. During this period (3-4 minutes after the smart plug is connected to the network), other devices can access the network, but the way to access the network seems to be similar to the smart plug (SP-EUC01).
  3. After 3-4 minutes, the log prints the end of the network connection time, and then the network is turned on again, but no device can be connected. The program can run normally only after restarting.

The above phenomenon was obtained after I carefully and repeatedly verified it. Therefore, I boldly guessed that this problem was caused by the smart plug (SP-EUC01) joining the network due to different processing methods. I added the log of my test to the attachment, including a series of procedures for the device to go online as described above, and a log of all the information that the mqtt subscribes to when the program is running. Among them, I made step instructions. log.zip

Frans-Willem commented 4 years ago

Thanks @DuanYuXian, I've created a separate issue for this. I'll try to order an SP-EUC01 and see if I can reproduce it :)

Frans-Willem commented 4 years ago

I've attempted to order an SP-EUC01, but was unable to do so. I hope to be able to re-investigate this when the SP-EUC01 will become easier to get hold of.

If anyone is willing to ship me an SP-EUC01 (to the Netherlands), please get in touch: fw@hardijzer.nl