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

Philips Hue White Bulb B22 support #61

Open ghost opened 4 years ago

ghost commented 4 years ago

I know, it's AqaraHub not HueHub, but I was hoping to avoid moving away from AqaraHub.

<DEBG> [OnPermitJoin] Published OK
<DEBG> [FRAME] << AREQ ZDO_MGMT_PERMIT_JOIN_RSP 00 00 00
<DEBG> [PermitJoin] Permit join OK
<DEBG> [FRAME] << AREQ ZDO_TC_DEV_IND 70 37 9c f6 63 04 01 88 17 00 00 00
<DEBG> [ZnpApi] Unhandled frame AREQ ZDO_TC_DEV_IND
<DEBG> [FRAME] << AREQ ZDO_END_DEVICE_ANNCE_IND 70 37 70 37 9c f6 63 04 01 88 17 00 8e
<DEBG> [ZnpApi] Unhandled frame AREQ ZDO_END_DEVICE_ANNCE_IND

I had a look at #59 but couldn't work out what my device address was.

Frans-Willem commented 4 years ago

I'll add some code to parse the TC_DEV_IND and ZDO_END_DEVICE_ANNCE_IND messages and log some more output and/or dump to MQTT later, but for now, I believe the TC_DEV_IND contains a short address in the first 2 bytes following it, in your case 70 37 formatted as little-endian or 0x3770 formatted as human-readable, and then the extended address, 9C F6 63 04 01 88 17 00 as little endian, is 0x001788010463F69C. Messages to this device should be sent to AqaraHub/001788010463F69C/ :)

I'm fairly certain most Philips hue bulbs should support at least the On/Off cluster, but I believe they should support much more, e.g. dimming ("Level Control"?) and color ("Color Control"?). Look in clusters.info for what's already implemented in AqaraHub, and expand it if needed. All information required to do so should be in the Zigbee Cluster Library spec.

Keep me posted on your results, and if you can spare the time, please file pull requests with updated documentation on the devices you tested :)

Frans-Willem commented 4 years ago

Could you check if pull request #62 or branch feature/inform-device-join works for you and makes it easier to get your joined devices addresses ?

ghost commented 4 years ago

Running the new code, I can definitely see the device address, but sending commands doesn't seem to work:

<DEBG> [FRAME] << AREQ ZDO_END_DEVICE_ANNCE_IND 70 37 70 37 9c f6 63 04 01 88 17 00 8e
<INFO> [OnEndDeviceAnnounce] End device announced: 001788010463F69C
<DEBG> [OnEndDeviceAnnounce] Published OK
<DEBG> [FRAME] << AREQ AF_INCOMING_MSG 00 00 02 04 d2 cd 01 01 00 37 00 9d fa 07 00 00 08 18 38 0a 00 00 29 a3 08 d2 cd 1d
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP d2 cd
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP d2 cd
<DEBG> [FRAME] << AREQ AF_INCOMING_MSG 00 00 05 04 d2 cd 01 01 00 37 00 aa fa 07 00 00 08 18 39 0a 00 00 21 6c 15 d2 cd 1d
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP d2 cd
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_NWK_ADDR_LOOKUP d2 cd
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 6c 9a 00 02 00 8d 15 00
<INFO> [PublishValue] Publishing to 'AqaraHub/00158D0002009A6C/1/in/Temperature Measurement/Report Attributes': {"reports":[{"Attribute data":{"type":"int16","value":2211},"Attribute identifier":"MeasuredValue"}]}
<INFO> [OnZclCommand] Looks like something per-attribute. Publishing per-attribute too
<INFO> [PublishValue] Publishing to 'AqaraHub/00158D0002009A6C/1/in/Temperature Measurement/Report Attributes/MeasuredValue': {"type":"int16","value":2211}
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 6c 9a 00 02 00 8d 15 00
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 6c 9a 00 02 00 8d 15 00
<INFO> [PublishValue] Publishing to 'AqaraHub/00158D0002009A6C/1/in/Relative Humidity Measurement/Report Attributes': {"reports":[{"Attribute data":{"type":"uint16","value":5484},"Attribute identifier":"MeasuredValue"}]}
<INFO> [OnZclCommand] Looks like something per-attribute. Publishing per-attribute too
<INFO> [PublishValue] Publishing to 'AqaraHub/00158D0002009A6C/1/in/Relative Humidity Measurement/Report Attributes/MeasuredValue': {"type":"uint16","value":5484}
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_NWK_ADDR_LOOKUP 6c 9a 00 02 00 8d 15 00
<DEBG> [OnPublishCommandShort] Destination 6623462414349980, endpoint 1, cluster name 'OnOff'
<INFO> [SendCommand] Encoded payload:
<INFO> [SendCommand] Looking up Short Address from IEEE address
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_EXT_ADDR_LOOKUP 9c f6 63 04 01 88 17 00
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_EXT_ADDR_LOOKUP 70 37
<INFO> [SendCommand] Response received, short address: 14192
<DEBG> [FRAME] >> SREQ AF_DATA_REQUEST 70 37 01 01 06 00 00 00 1e 03 01 00 00
<DEBG> [FRAME] << SRSP AF_DATA_REQUEST 00
<DEBG> [FRAME] << AREQ AF_DATA_CONFIRM 00 01 00
<INFO> [SendCommand] Command sent
<DEBG> [OnPublishCommandShort] Destination 6623462414349980, endpoint 1, cluster name 'OnOff'
<INFO> [SendCommand] Encoded payload:
<INFO> [SendCommand] Looking up Short Address from IEEE address
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_EXT_ADDR_LOOKUP 9c f6 63 04 01 88 17 00
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_EXT_ADDR_LOOKUP 70 37
<INFO> [SendCommand] Response received, short address: 14192
<DEBG> [FRAME] >> SREQ AF_DATA_REQUEST 70 37 01 01 06 00 00 00 1e 03 01 01 00
<DEBG> [FRAME] << SRSP AF_DATA_REQUEST 00
<DEBG> [FRAME] << AREQ AF_DATA_CONFIRM 00 01 00
<INFO> [SendCommand] Command sent
<DEBG> [OnPublishCommandShort] Destination 6623462414349980, endpoint 1, cluster name 'OnOff'
<INFO> [SendCommand] Encoded payload:
<INFO> [SendCommand] Looking up Short Address from IEEE address
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_EXT_ADDR_LOOKUP 9c f6 63 04 01 88 17 00
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_EXT_ADDR_LOOKUP 70 37
<INFO> [SendCommand] Response received, short address: 14192
<DEBG> [FRAME] >> SREQ AF_DATA_REQUEST 70 37 01 01 06 00 00 00 1e 03 01 02 01
<DEBG> [FRAME] << SRSP AF_DATA_REQUEST 00
<DEBG> [FRAME] << AREQ AF_DATA_CONFIRM 00 01 00
<INFO> [SendCommand] Command sent
<DEBG> [OnPublishCommandShort] Destination 6623462414349980, endpoint 1, cluster name 'OnOff'
<INFO> [SendCommand] Encoded payload:
<INFO> [SendCommand] Looking up Short Address from IEEE address
<DEBG> [FRAME] >> SREQ UTIL_ADDRMGR_EXT_ADDR_LOOKUP 9c f6 63 04 01 88 17 00
<DEBG> [FRAME] << SRSP UTIL_ADDRMGR_EXT_ADDR_LOOKUP 70 37
<INFO> [SendCommand] Response received, short address: 14192
<DEBG> [FRAME] >> SREQ AF_DATA_REQUEST 70 37 01 01 06 00 00 00 1e 03 01 03 00
<DEBG> [FRAME] << SRSP AF_DATA_REQUEST 00
<DEBG> [FRAME] << AREQ AF_DATA_CONFIRM 00 01 00
<INFO> [SendCommand] Command sent
<DEBG> [FRAME] << AREQ ZDO_PERMIT_JOIN_IND 00
<DEBG> [OnPermitJoin] Published OK
Frans-Willem commented 4 years ago

That's a bummer, did you try the Level Control or Color Control too ? Take a peek through clusters.info what's supported. For example the On/Off section has a bunch of attributes as well as "On" or "Off" commands described in there: https://github.com/Frans-Willem/AqaraHub/blob/master/clusters.info#L227

There's also "Level Control" and "Color Control" with a bunch of attributes and commands: https://github.com/Frans-Willem/AqaraHub/blob/master/clusters.info#L259 https://github.com/Frans-Willem/AqaraHub/blob/master/clusters.info#L521

Maybe the device supports those 'clusters' instead ?

Also, could you give me a type number of which device you're trying to talk to? I could see if I could pick one up here and play with it :) Most Zigbee devices work, but it's a bit of puzzle to figure out which parts exactly of the Zigbee Cluster Library they support.

ghost commented 4 years ago

Sorry, coming back to this after... a few months.

The light I bought was a "Philips Hue White Bulb B22", as far as I know no colour control, probably brightness only. I have a new CC2531 stick flashed and am working on this again