Don't bind all clusters unconditionally (#49793)

pull/49828/head
Alexei Chetroi 2021-04-27 20:25:34 -04:00 committed by GitHub
parent 575b8340fc
commit 345873f94f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 11 deletions

View File

@ -88,6 +88,7 @@ class ZigbeeChannel(LogMixin):
"""Base channel for a Zigbee cluster."""
REPORT_CONFIG = ()
BIND: bool = True
def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
@ -247,7 +248,8 @@ class ZigbeeChannel(LogMixin):
async def async_configure(self) -> None:
"""Set cluster binding and attribute reporting."""
if not self._ch_pool.skip_configuration:
await self.bind()
if self.BIND:
await self.bind()
if self.cluster.is_server:
await self.configure_reporting()
ch_specific_cfg = getattr(self, "async_configure_channel_specific", None)

View File

@ -138,6 +138,7 @@ class BasicChannel(ZigbeeChannel):
UNKNOWN = 0
BATTERY = 3
BIND: bool = False
POWER_SOURCES = {
UNKNOWN: "Unknown",
@ -185,16 +186,22 @@ class DeviceTemperature(ZigbeeChannel):
class GreenPowerProxy(ZigbeeChannel):
"""Green Power Proxy channel."""
BIND: bool = False
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.Groups.cluster_id)
class Groups(ZigbeeChannel):
"""Groups channel."""
BIND: bool = False
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.Identify.cluster_id)
class Identify(ZigbeeChannel):
"""Identify channel."""
BIND: bool = False
@callback
def cluster_command(self, tsn, command_id, args):
"""Handle commands received to this cluster."""
@ -368,6 +375,8 @@ class OnOffConfiguration(ZigbeeChannel):
class Ota(ZigbeeChannel):
"""OTA Channel."""
BIND: bool = False
@callback
def cluster_command(
self, tsn: int, command_id: int, args: list[Any] | None

View File

@ -13,6 +13,8 @@ from .base import ChannelStatus, ZigbeeChannel
class LightLink(ZigbeeChannel):
"""Lightlink channel."""
BIND: bool = False
async def async_configure(self) -> None:
"""Add Coordinator to LightLink group ."""

View File

@ -97,10 +97,10 @@ async def poll_control_device(zha_device_restored, zigpy_device_mock):
@pytest.mark.parametrize(
"cluster_id, bind_count, attrs",
[
(0x0000, 1, {}),
(0x0000, 0, {}),
(0x0001, 1, {"battery_voltage", "battery_percentage_remaining"}),
(0x0003, 1, {}),
(0x0004, 1, {}),
(0x0003, 0, {}),
(0x0004, 0, {}),
(0x0005, 1, {}),
(0x0006, 1, {"on_off"}),
(0x0007, 1, {}),
@ -117,11 +117,11 @@ async def poll_control_device(zha_device_restored, zigpy_device_mock):
(0x0014, 1, {"present_value"}),
(0x0015, 1, {}),
(0x0016, 1, {}),
(0x0019, 1, {}),
(0x0019, 0, {}),
(0x001A, 1, {}),
(0x001B, 1, {}),
(0x0020, 1, {}),
(0x0021, 1, {}),
(0x0021, 0, {}),
(0x0101, 1, {"lock_state"}),
(0x0202, 1, {"fan_mode"}),
(0x0300, 1, {"current_x", "current_y", "color_temperature"}),
@ -164,10 +164,10 @@ async def test_in_channel_config(
@pytest.mark.parametrize(
"cluster_id, bind_count",
[
(0x0000, 1),
(0x0000, 0),
(0x0001, 1),
(0x0003, 1),
(0x0004, 1),
(0x0003, 0),
(0x0004, 0),
(0x0005, 1),
(0x0006, 1),
(0x0007, 1),
@ -175,11 +175,11 @@ async def test_in_channel_config(
(0x0009, 1),
(0x0015, 1),
(0x0016, 1),
(0x0019, 1),
(0x0019, 0),
(0x001A, 1),
(0x001B, 1),
(0x0020, 1),
(0x0021, 1),
(0x0021, 0),
(0x0101, 1),
(0x0202, 1),
(0x0300, 1),