Better pairing for Xiaomi devices in ZHA (#24564)

* better xiaomi pairing
* cleanup.
This commit is contained in:
David F. Mulcahey 2019-06-18 11:36:28 -04:00 committed by Alexei Chetroi
parent 76549beb96
commit 227b8bdf8a
2 changed files with 22 additions and 20 deletions

View File

@ -14,7 +14,7 @@ from random import uniform
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_send
from ..helpers import (
bind_configure_reporting, construct_unique_id,
configure_reporting, construct_unique_id,
safe_read, get_attr_id_by_name, bind_cluster)
from ..const import (
REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED, ATTRIBUTE_CHANNEL,
@ -133,26 +133,25 @@ class ZigbeeChannel:
"""Set cluster binding and attribute reporting."""
manufacturer = None
manufacturer_code = self._zha_device.manufacturer_code
# Xiaomi devices don't need this and it disrupts pairing
if self._zha_device.manufacturer != 'LUMI':
if self.cluster.cluster_id >= 0xfc00 and manufacturer_code:
manufacturer = manufacturer_code
if self.cluster.bind_only:
await bind_cluster(self._unique_id, self.cluster)
else:
skip_bind = False # bind cluster only for the 1st configured attr
if not self.cluster.bind_only:
for report_config in self._report_config:
attr = report_config.get('attr')
min_report_interval, max_report_interval, change = \
report_config.get('config')
await bind_configure_reporting(
await configure_reporting(
self._unique_id, self.cluster, attr,
min_report=min_report_interval,
max_report=max_report_interval,
reportable_change=change,
skip_bind=skip_bind,
manufacturer=manufacturer
)
skip_bind = True
await asyncio.sleep(uniform(0.1, 0.5))
_LOGGER.debug(
"%s: finished channel configuration",
self._unique_id

View File

@ -35,6 +35,9 @@ class IASZoneChannel(ZigbeeChannel):
async def async_configure(self):
"""Configure IAS device."""
# Xiaomi devices don't need this and it disrupts pairing
if self._zha_device.manufacturer == 'LUMI':
return
from zigpy.exceptions import DeliveryError
_LOGGER.debug("%s: started IASZoneChannel configuration",
self._unique_id)