doudz / zigate

python lib for zigate
MIT License
46 stars 22 forks source link

Auto discovery fail when device as no type attribute #74

Closed jBouyoud closed 5 years ago

jBouyoud commented 5 years ago

Hello,

I recently update my zigate module to 0.25.1. And attributes auto-discorevy/reporting seems to be broken with device that doesn't have type (5) attributes on General cluster (0) which is unfortunalty the case for my device a Profalux cover.

You can see debug logs below :

> z.read_attribute_request('f641', 1, 0, 5)
DEBUG:zigate:REQUEST : 0x0100 b'\x02\xf6A\x01\x01\x00\x00\x00\x00\x00\x00\x01\x00\x05'
DEBUG:zigate:Msg to send b'0100000ebe02f6410101000000000000010005'
DEBUG:zigate:Encoded Msg to send b'01021102100210021ebe0212f6410211021102100210021002100210021002110210021503'
DEBUG:zigate:Waiting for status message for command 0x0100
DEBUG:zigate:Raw packet received, b'\x01\x80\x02\x10\x02\x10\x02\x15\xc1\x02\x10E\x02\x11\x02\x10\x02\x10\x03\x01\x81\x02\x12\x02\x10\x02\x1d2E\xf6A\x02\x11\x02\x10\x02\x10\x02\x10\x02\x15\x86\xff\x02\x10\x02\x103\x03'
DEBUG:zigate:Dispatch ZIGATE_PACKET_RECEIVED
DEBUG:zigate:Received response 0x8000: b'00450100'
DEBUG:zigate:Dispatch ZIGATE_PACKET_RECEIVED
DEBUG:zigate:RESPONSE 0x8000 - Status response : status:0, sequence:69, packet_type:256, error:b'', rssi:0
DEBUG:zigate:Dispatch ZIGATE_RESPONSE_RECEIVED
DEBUG:zigate:Received response 0x8102: b'45f641010000000586ff0000'
DEBUG:zigate:RESPONSE 0x8102 - Individual Attribute Report : sequence:69, addr:f641, endpoint:1, cluster:0, attribute:5, status:134, data_type:255, size:0, data:, rssi:51
DEBUG:zigate:Dispatch ZIGATE_RESPONSE_RECEIVED
DEBUG:zigate:STATUS code to command 0x0100:0
DEBUG:zigate:Received Bad status

I receive a 134 (0x86) status code, according to this doc https://www.nxp.com/docs/en/user-guide/JN-UG-3115.pdf#page=156&zoom=100,0,221 , P154 Chapter 7.1.4 E_ZCL_CMDS_UNSUPPORTED_ATTRIBUTE , It seems to match.

With an older version of zigate, I've got the following auto discovered attributes for 0 cluster.

{
                            "attributes": [
                                {
                                    "attribute": 0,
                                    "data": 1,
                                    "name": "zcl_version",
                                    "value": 1
                                },
                                {
                                    "attribute": 6,
                                    "data": "20140909338X337",
                                    "name": "datecode",
                                    "value": "20140909338X337"
                                },
                                {
                                    "attribute": 7,
                                    "data": 0,
                                    "name": "power_source",
                                    "value": 0
                                },
                                {
                                    "attribute": 16,
                                    "data": "BSO",
                                    "name": "description",
                                    "value": "BSO"
                                }
                            ],
                            "cluster": 0
                        }

Also you can found other info about the device below :

"info": {
                "addr": "dd3d", <= Not the same because I reset and re-sync my device 
                "bit_field": "0100000000000001",
                "descriptor_capability": "00000000",
                "id": 50,
                "ieee": "20918a0000000000", 
                "last_seen": "2019-01-19 10:11:53",
                "mac_capability": "10001110",
                "manufacturer": "1110",
                "max_buffer": 82,
                "max_rx": 82,
                "max_tx": 82,
                "power_type": 1,
                "rssi": 96,
                "server_mask": 0
            }
doudz commented 5 years ago

No, I have removed the full attributes reading because it's almost unneeded. That's why it only try to read attribute 5 now it's not a bug

jBouyoud commented 5 years ago

I see that you have just fix this issue (https://github.com/doudz/zigate/commit/e68817694981808e3a45d670e69d9889cc89ef80#diff-d508f2d159253fda151b62cd6971c50dR542 ) Thank You