From 0d23d8dc090b3132b79bc5e2321fb46830d0ee1d Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Wed, 4 Mar 2026 09:57:07 +0100 Subject: [PATCH] Bump ZHA to 1.0.1 (#164709) --- homeassistant/components/zha/cover.py | 14 +++- homeassistant/components/zha/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/zha/test_cover.py | 83 +++++++++++++++++++++- 5 files changed, 96 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/zha/cover.py b/homeassistant/components/zha/cover.py index 36b9a001506..213d5d11150 100644 --- a/homeassistant/components/zha/cover.py +++ b/homeassistant/components/zha/cover.py @@ -67,8 +67,12 @@ class ZhaCover(ZHAEntity, CoverEntity): self.entity_data.entity.info_object.device_class ) + @staticmethod + def _convert_supported_features( + zha_features: ZHACoverEntityFeature, + ) -> CoverEntityFeature: + """Convert ZHA cover features to HA cover features.""" features = CoverEntityFeature(0) - zha_features: ZHACoverEntityFeature = self.entity_data.entity.supported_features if ZHACoverEntityFeature.OPEN in zha_features: features |= CoverEntityFeature.OPEN @@ -87,7 +91,13 @@ class ZhaCover(ZHAEntity, CoverEntity): if ZHACoverEntityFeature.SET_TILT_POSITION in zha_features: features |= CoverEntityFeature.SET_TILT_POSITION - self._attr_supported_features = features + return features + + @property + def supported_features(self) -> CoverEntityFeature: + """Return the supported features.""" + zha_features: ZHACoverEntityFeature = self.entity_data.entity.supported_features + return self._convert_supported_features(zha_features) @property def is_closed(self) -> bool | None: diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index 4d1dc805922..f1ac7ee7554 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -23,7 +23,7 @@ "universal_silabs_flasher", "serialx" ], - "requirements": ["zha==1.0.0", "serialx==0.6.2"], + "requirements": ["zha==1.0.1", "serialx==0.6.2"], "usb": [ { "description": "*2652*", diff --git a/requirements_all.txt b/requirements_all.txt index 509f72fd232..5233e6b20aa 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -3350,7 +3350,7 @@ zeroconf==0.148.0 zeversolar==0.3.2 # homeassistant.components.zha -zha==1.0.0 +zha==1.0.1 # homeassistant.components.zhong_hong zhong-hong-hvac==1.0.13 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 6386b528167..a0fc1594d1a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2823,7 +2823,7 @@ zeroconf==0.148.0 zeversolar==0.3.2 # homeassistant.components.zha -zha==1.0.0 +zha==1.0.1 # homeassistant.components.zinvolt zinvolt==0.3.0 diff --git a/tests/components/zha/test_cover.py b/tests/components/zha/test_cover.py index 133a7fe612b..6d7739243b4 100644 --- a/tests/components/zha/test_cover.py +++ b/tests/components/zha/test_cover.py @@ -22,6 +22,7 @@ from homeassistant.components.cover import ( SERVICE_SET_COVER_TILT_POSITION, SERVICE_STOP_COVER, SERVICE_STOP_COVER_TILT, + CoverEntityFeature, CoverState, ) from homeassistant.components.zha.helpers import ( @@ -332,6 +333,70 @@ async def test_cover( assert cluster.request.call_args[1]["expect_reply"] is True +async def test_cover_supported_features_runtime_update( + hass: HomeAssistant, + setup_zha: Callable[..., Coroutine[None]], + zigpy_device_mock: Callable[..., Device], +) -> None: + """Test ZHA cover supported features update at runtime.""" + await setup_zha() + gateway = get_zha_gateway(hass) + gateway_proxy: ZHAGatewayProxy = get_zha_gateway_proxy(hass) + + zigpy_device = zigpy_device_mock( + { + 1: { + SIG_EP_PROFILE: zha.PROFILE_ID, + SIG_EP_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE, + SIG_EP_INPUT: [closures.WindowCovering.cluster_id], + SIG_EP_OUTPUT: [], + } + }, + ) + cluster = zigpy_device.endpoints[1].window_covering + cluster.PLUGGED_ATTR_READS = { + WCAttrs.current_position_lift_percentage.name: 0, + WCAttrs.current_position_tilt_percentage.name: 100, + WCAttrs.window_covering_type.name: WCT.Tilt_blind_tilt_and_lift, + WCAttrs.config_status.name: WCCS(~WCCS.Open_up_commands_reversed), + } + update_attribute_cache(cluster) + + gateway.get_or_create_device(zigpy_device) + await gateway.async_device_initialized(zigpy_device) + await hass.async_block_till_done(wait_background_tasks=True) + + zha_device_proxy: ZHADeviceProxy = gateway_proxy.get_device_proxy(zigpy_device.ieee) + entity_id = find_entity_id(Platform.COVER, zha_device_proxy, hass) + assert entity_id is not None + + await async_update_entity(hass, entity_id) + state = hass.states.get(entity_id) + assert state + assert state.attributes["supported_features"] == ( + CoverEntityFeature.OPEN + | CoverEntityFeature.CLOSE + | CoverEntityFeature.SET_POSITION + | CoverEntityFeature.STOP + | CoverEntityFeature.OPEN_TILT + | CoverEntityFeature.CLOSE_TILT + | CoverEntityFeature.STOP_TILT + | CoverEntityFeature.SET_TILT_POSITION + ) + + await send_attributes_report( + hass, cluster, {WCAttrs.window_covering_type.id: WCT.Tilt_blind_tilt_only} + ) + state = hass.states.get(entity_id) + assert state + assert state.attributes["supported_features"] == ( + CoverEntityFeature.OPEN_TILT + | CoverEntityFeature.CLOSE_TILT + | CoverEntityFeature.STOP_TILT + | CoverEntityFeature.SET_TILT_POSITION + ) + + async def test_cover_failures( hass: HomeAssistant, setup_zha: Callable[..., Coroutine[None]], @@ -369,11 +434,25 @@ async def test_cover_failures( assert entity_id is not None # test that the state has changed from unavailable to closed - await send_attributes_report(hass, cluster, {0: 0, 8: 100, 1: 1}) + await send_attributes_report( + hass, + cluster, + { + WCAttrs.current_position_lift_percentage.id: 100, + WCAttrs.current_position_tilt_percentage.id: 100, + }, + ) assert hass.states.get(entity_id).state == CoverState.CLOSED # test that it opens - await send_attributes_report(hass, cluster, {0: 1, 8: 0, 1: 100}) + await send_attributes_report( + hass, + cluster, + { + WCAttrs.current_position_lift_percentage.id: 0, + WCAttrs.current_position_tilt_percentage.id: 0, + }, + ) assert hass.states.get(entity_id).state == CoverState.OPEN # close from UI