Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZHA pairing results in an error #17886

Closed
frog32 opened this issue Oct 27, 2018 · 7 comments
Closed

ZHA pairing results in an error #17886

frog32 opened this issue Oct 27, 2018 · 7 comments

Comments

@frog32
Copy link
Contributor

frog32 commented Oct 27, 2018

Home Assistant release with the issue:
0.81.0

Last working Home Assistant release (if known):
unknown
This originally worked but stopped working a few weeks ago without a version change of HA. After that I deleted the zigbee.db it stopped failing.

Operating environment (Hass.io/Docker/Windows/etc.):

hassio 32bit rpi
elelabs USB dongle https://www.tindie.com/products/Elelabs/elelabs-zigbee-usb-adapter/

Component/platform: zha

Description of problem:
After starting with a deleted zigbee.db and power cycling everything the database gets recreated but it seems that most tables are empty

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

zha:
  usb_path: /dev/ttyUSB0
  database_path: zigbee.db

Traceback (if applicable):

2018-10-27 18:10:27 DEBUG (MainThread) [bellows.ezsp] Send command permitJoining
2018-10-27 18:10:27 DEBUG (MainThread) [bellows.ezsp] Application frame 34 (permitJoining) received
2018-10-27 18:10:41 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
2018-10-27 18:10:41 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
2018-10-27 18:10:41 INFO (MainThread) [zigpy.application] Device 0x25e4 (00:15:8d:00:02:47:88:62) left the network
2018-10-27 18:10:43 DEBUG (MainThread) [bellows.ezsp] Application frame 35 (childJoinHandler) received
2018-10-27 18:10:43 DEBUG (MainThread) [bellows.ezsp] Application frame 196 (changeSourceRouteHandler) received
2018-10-27 18:10:44 DEBUG (MainThread) [bellows.ezsp] Application frame 36 (trustCenterJoinHandler) received
2018-10-27 18:10:44 INFO (MainThread) [zigpy.application] Device 0x516e (00:15:8d:00:02:47:88:62) joined the network
2018-10-27 18:10:44 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
2018-10-27 18:10:44 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
2018-10-27 18:10:44 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:44 DEBUG (MainThread) [zigpy.zdo] [0x516e:zdo] ZDO request 0x0013: [20846, 00:15:8d:00:02:47:88:62, 128]
2018-10-27 18:10:44 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:44 ERROR (MainThread) [bellows.ezsp] Exception running handler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/bellows/ezsp.py", line 194, in handle_callback
    handler(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 139, in ezsp_callback_handler
    self._handle_frame(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 160, in _handle_frame
    tsn, command_id, is_reply, args = self.deserialize(device, aps_frame.sourceEndpoint, aps_frame.clusterId, message)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2018-10-27 18:10:45 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:45 ERROR (MainThread) [bellows.ezsp] Exception running handler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/bellows/ezsp.py", line 194, in handle_callback
    handler(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 139, in ezsp_callback_handler
    self._handle_frame(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 160, in _handle_frame
    tsn, command_id, is_reply, args = self.deserialize(device, aps_frame.sourceEndpoint, aps_frame.clusterId, message)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1
2018-10-27 18:10:45 DEBUG (MainThread) [bellows.ezsp] Application frame 63 (messageSentHandler) received
2018-10-27 18:10:45 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:45 DEBUG (MainThread) [bellows.ezsp] Send command sendUnicast
2018-10-27 18:10:45 DEBUG (MainThread) [bellows.ezsp] Application frame 52 (sendUnicast) received
2018-10-27 18:10:48 DEBUG (MainThread) [bellows.ezsp] Application frame 128 (incomingRouteErrorHandler) received
2018-10-27 18:10:49 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:49 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:49 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=3 command=266 args=b'\x00\x00!T\x1b'
2018-10-27 18:10:49 WARNING (MainThread) [zigpy.endpoint] [0x516e:1] Message on unknown cluster 0x0405
2018-10-27 18:10:49 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-10-27 18:10:49 WARNING (MainThread) [bellows.zigbee.application] Unexpected response TSN=4 command=266 args=b'\x00\x00)\xb5\x03\x14\x00(\xff\x10\x00)\x1b%'
2018-10-27 18:10:49 WARNING (MainThread) [zigpy.endpoint] [0x516e:1] Message on unknown cluster 0x0403

Additional information:
After that bellows shows frequent errors and there seems to be a difference between the Zigbee dongles state and the state as seen from home assistant

@frog32
Copy link
Contributor Author

frog32 commented Oct 29, 2018

This turned out to be an issue with the Xiaomi devices that I have in my network. There is an issue reported against zigpy that has some ideas on how to fix this. Should I document how to pair Xiaomi devices to prevent the next user to run into the same issue? Do we want to have device specific documentation in HA?
zigpy/zigpy#9

@k-wie
Copy link

k-wie commented Nov 4, 2018

I'm experiencing the same issue after adding a Xiaomi humidity and temperature sensor to Home Assistant 0.81 via the Elelabs Zigbee USB adapter..how did you solve it @frog32 ?

2018-11-02 13:55:04 ERROR (MainThread) [bellows.ezsp] Exception running handler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/bellows/ezsp.py", line 194, in handle_callback
    handler(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 139, in ezsp_callback_handler
    self._handle_frame(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 160, in _handle_frame
    tsn, command_id, is_reply, args = self.deserialize(device, aps_frame.sourceEndpoint, aps_frame.clusterId, message)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1

@leonetnl
Copy link

leonetnl commented Nov 4, 2018

Same issue, on 0.81.5. Please share you documentation @frog32

2018-11-04 13:43:05 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-11-04 13:43:05 ERROR (MainThread) [bellows.ezsp] Exception running handler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/bellows/ezsp.py", line 194, in handle_callback
    handler(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 139, in ezsp_callback_handler
    self._handle_frame(*args)
  File "/usr/local/lib/python3.6/site-packages/bellows/zigbee/application.py", line 160, in _handle_frame
    tsn, command_id, is_reply, args = self.deserialize(device, aps_frame.sourceEndpoint, aps_frame.clusterId, message)
  File "/usr/local/lib/python3.6/site-packages/zigpy/application.py", line 73, in deserialize
    return sender.deserialize(endpoint_id, cluster_id, data)
  File "/usr/local/lib/python3.6/site-packages/zigpy/device.py", line 97, in deserialize
    return self.endpoints[endpoint_id].deserialize(cluster_id, data)
KeyError: 1

@frog32
Copy link
Contributor Author

frog32 commented Nov 4, 2018

Some xiaomi devices are too sleepy. They go to sleep before the pairing is complete and do not announce all their clusters. To prevent that from happening I had to keep pressing the button on my humidity sensor every ~4s which does not influence the pairing but prevents the sensor from going to sleep. After 30s or so I had all required clusters in the database.

@k-wie
Copy link

k-wie commented Nov 5, 2018

Wauw, that's it! I've been struggling already a few weeks now, thanks a lot!

@dmulcahey
Copy link
Contributor

@cgarwood can we close this as a known issue w/ Xiaomi devices? see this link for more info: https://community.smartthings.com/t/original-aqara-xiaomi-zigbee-sensors-contact-temp-motion-button-outlet-leak-etc/113253

This is a problem with other zigbee platforms as well. For the Xiaomi devices you have to keep them awake while pairing or they will not report their cluster information correctly. Pressing their button 1 time every 5 seconds or so seems to work very well.

@cgarwood
Copy link
Member

Makes sense, not much we can do if the hardware is going to sleep too fast.

@home-assistant home-assistant locked and limited conversation to collaborators Mar 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants