mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +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.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from ..helpers import (
|
from ..helpers import (
|
||||||
bind_configure_reporting, construct_unique_id,
|
configure_reporting, construct_unique_id,
|
||||||
safe_read, get_attr_id_by_name, bind_cluster)
|
safe_read, get_attr_id_by_name, bind_cluster)
|
||||||
from ..const import (
|
from ..const import (
|
||||||
REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED, ATTRIBUTE_CHANNEL,
|
REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED, ATTRIBUTE_CHANNEL,
|
||||||
@ -133,26 +133,25 @@ class ZigbeeChannel:
|
|||||||
"""Set cluster binding and attribute reporting."""
|
"""Set cluster binding and attribute reporting."""
|
||||||
manufacturer = None
|
manufacturer = None
|
||||||
manufacturer_code = self._zha_device.manufacturer_code
|
manufacturer_code = self._zha_device.manufacturer_code
|
||||||
if self.cluster.cluster_id >= 0xfc00 and manufacturer_code:
|
# Xiaomi devices don't need this and it disrupts pairing
|
||||||
manufacturer = manufacturer_code
|
if self._zha_device.manufacturer != 'LUMI':
|
||||||
if self.cluster.bind_only:
|
if self.cluster.cluster_id >= 0xfc00 and manufacturer_code:
|
||||||
|
manufacturer = manufacturer_code
|
||||||
await bind_cluster(self._unique_id, self.cluster)
|
await bind_cluster(self._unique_id, self.cluster)
|
||||||
else:
|
if not self.cluster.bind_only:
|
||||||
skip_bind = False # bind cluster only for the 1st configured attr
|
for report_config in self._report_config:
|
||||||
for report_config in self._report_config:
|
attr = report_config.get('attr')
|
||||||
attr = report_config.get('attr')
|
min_report_interval, max_report_interval, change = \
|
||||||
min_report_interval, max_report_interval, change = \
|
report_config.get('config')
|
||||||
report_config.get('config')
|
await configure_reporting(
|
||||||
await bind_configure_reporting(
|
self._unique_id, self.cluster, attr,
|
||||||
self._unique_id, self.cluster, attr,
|
min_report=min_report_interval,
|
||||||
min_report=min_report_interval,
|
max_report=max_report_interval,
|
||||||
max_report=max_report_interval,
|
reportable_change=change,
|
||||||
reportable_change=change,
|
manufacturer=manufacturer
|
||||||
skip_bind=skip_bind,
|
)
|
||||||
manufacturer=manufacturer
|
await asyncio.sleep(uniform(0.1, 0.5))
|
||||||
)
|
|
||||||
skip_bind = True
|
|
||||||
await asyncio.sleep(uniform(0.1, 0.5))
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"%s: finished channel configuration",
|
"%s: finished channel configuration",
|
||||||
self._unique_id
|
self._unique_id
|
||||||
|
@ -35,6 +35,9 @@ class IASZoneChannel(ZigbeeChannel):
|
|||||||
|
|
||||||
async def async_configure(self):
|
async def async_configure(self):
|
||||||
"""Configure IAS device."""
|
"""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
|
from zigpy.exceptions import DeliveryError
|
||||||
_LOGGER.debug("%s: started IASZoneChannel configuration",
|
_LOGGER.debug("%s: started IASZoneChannel configuration",
|
||||||
self._unique_id)
|
self._unique_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user