zigpy / zha

Zigbee Home Automation
Apache License 2.0
10 stars 4 forks source link

Expose `supported_features` as a property #69

Closed puddly closed 2 weeks ago

puddly commented 2 weeks ago

Fixes internal attribute access in ZHA:

diff --git a/homeassistant/components/zha/cover.py b/homeassistant/components/zha/cover.py
index 066cb6524a8..c3e4890fcc1 100644
--- a/homeassistant/components/zha/cover.py
+++ b/homeassistant/components/zha/cover.py
@@ -68,9 +68,8 @@ class ZhaCover(ZHAEntity, CoverEntity):
             )

         features = CoverEntityFeature(0)
-        zha_features: ZHACoverEntityFeature = (
-            self.entity_data.entity._attr_supported_features  # noqa: SLF001
-        )
+        zha_features: ZHACoverEntityFeature = self.entity_data.entity.supported_features
+
         if ZHACoverEntityFeature.OPEN in zha_features:
             features |= CoverEntityFeature.OPEN
         if ZHACoverEntityFeature.CLOSE in zha_features:
diff --git a/homeassistant/components/zha/siren.py b/homeassistant/components/zha/siren.py
index bed90ef8f22..9d876d9ca4d 100644
--- a/homeassistant/components/zha/siren.py
+++ b/homeassistant/components/zha/siren.py
@@ -74,9 +74,7 @@ class ZHASiren(ZHAEntity, SirenEntity):
         super().__init__(entity_data, **kwargs)

         features: SirenEntityFeature = SirenEntityFeature(0)
-        zha_features: ZHASirenEntityFeature = (
-            self.entity_data.entity._attr_supported_features  # noqa: SLF001
-        )
+        zha_features: ZHASirenEntityFeature = self.entity_data.entity.supported_features

         if ZHASirenEntityFeature.TURN_ON in zha_features:
             features |= SirenEntityFeature.TURN_ON
codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.37%. Comparing base (26a1316) to head (0b8da2f). Report is 1 commits behind head on dev.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #69 +/- ## ======================================= Coverage 95.37% 95.37% ======================================= Files 61 61 Lines 9341 9350 +9 ======================================= + Hits 8909 8918 +9 Misses 432 432 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.