mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Better pairing for Xiaomi devices in ZHA (#24564)
* better xiaomi pairing * cleanup.
This commit is contained in:
parent
76549beb96
commit
227b8bdf8a
@ -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
|
||||
if self.cluster.cluster_id >= 0xfc00 and manufacturer_code:
|
||||
manufacturer = manufacturer_code
|
||||
if self.cluster.bind_only:
|
||||
# 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
|
||||
await bind_cluster(self._unique_id, self.cluster)
|
||||
else:
|
||||
skip_bind = False # bind cluster only for the 1st configured attr
|
||||
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(
|
||||
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))
|
||||
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 configure_reporting(
|
||||
self._unique_id, self.cluster, attr,
|
||||
min_report=min_report_interval,
|
||||
max_report=max_report_interval,
|
||||
reportable_change=change,
|
||||
manufacturer=manufacturer
|
||||
)
|
||||
await asyncio.sleep(uniform(0.1, 0.5))
|
||||
|
||||
_LOGGER.debug(
|
||||
"%s: finished channel configuration",
|
||||
self._unique_id
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user