From 345873f94f78aa15d2ae3eb38b670e5d850d74dc Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Tue, 27 Apr 2021 20:25:34 -0400 Subject: [PATCH] Don't bind all clusters unconditionally (#49793) --- .../components/zha/core/channels/base.py | 4 +++- .../components/zha/core/channels/general.py | 9 +++++++++ .../components/zha/core/channels/lightlink.py | 2 ++ tests/components/zha/test_channels.py | 20 +++++++++---------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/zha/core/channels/base.py b/homeassistant/components/zha/core/channels/base.py index 4d1e71e884e..e38e9e992da 100644 --- a/homeassistant/components/zha/core/channels/base.py +++ b/homeassistant/components/zha/core/channels/base.py @@ -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) diff --git a/homeassistant/components/zha/core/channels/general.py b/homeassistant/components/zha/core/channels/general.py index 881a4512bef..a0c2c3bc699 100644 --- a/homeassistant/components/zha/core/channels/general.py +++ b/homeassistant/components/zha/core/channels/general.py @@ -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 diff --git a/homeassistant/components/zha/core/channels/lightlink.py b/homeassistant/components/zha/core/channels/lightlink.py index 600493e8a12..e42a3b20053 100644 --- a/homeassistant/components/zha/core/channels/lightlink.py +++ b/homeassistant/components/zha/core/channels/lightlink.py @@ -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 .""" diff --git a/tests/components/zha/test_channels.py b/tests/components/zha/test_channels.py index f60b7d4859a..bd7fd3f9207 100644 --- a/tests/components/zha/test_channels.py +++ b/tests/components/zha/test_channels.py @@ -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),