From ad784e6c9df46f9ebf0aa79f13a26c4073468019 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Wed, 6 Jul 2022 23:10:52 +0200 Subject: [PATCH] Remove legacy cover --- pydeconz/models/light/cover.py | 8 ---- tests/lights/test_cover.py | 67 ---------------------------------- 2 files changed, 75 deletions(-) diff --git a/pydeconz/models/light/cover.py b/pydeconz/models/light/cover.py index 13281d7f..a6a090cf 100644 --- a/pydeconz/models/light/cover.py +++ b/pydeconz/models/light/cover.py @@ -11,10 +11,8 @@ class TypedCoverState(TypedDict): """Cover state type definition.""" - bri: int lift: int open: bool - sat: int tilt: int @@ -40,8 +38,6 @@ class Cover(LightBase): @property def is_open(self) -> bool: """Is cover open.""" - if "open" not in self.raw["state"]: # Legacy support - return self.state is False return self.raw["state"]["open"] @property @@ -51,8 +47,6 @@ def lift(self) -> int: Supported values: 0-100 - 0 is open / 100 is closed """ - if "lift" not in self.raw["state"]: # Legacy support - return int(self.raw["state"]["bri"] / 2.54) return self.raw["state"]["lift"] @property @@ -64,8 +58,6 @@ def tilt(self) -> int | None: """ if "tilt" in self.raw["state"]: return self.raw["state"]["tilt"] - elif "sat" in self.raw["state"]: # Legacy support - return int(self.raw["state"]["sat"] / 2.54) return None @property diff --git a/tests/lights/test_cover.py b/tests/lights/test_cover.py index 5015b197..a54ab596 100644 --- a/tests/lights/test_cover.py +++ b/tests/lights/test_cover.py @@ -27,24 +27,6 @@ "uniqueid": "xx:xx:xx:xx:xx:xx:xx:xx-01", } -DATA_LEGACY = { - "etag": "87269755b9b3a046485fdae8d96b252c", - "hascolor": False, - "lastannounced": None, - "lastseen": "2020-08-01T16:22:05Z", - "manufacturername": "AXIS", - "modelid": "Gear", - "name": "Covering device", - "state": { - "bri": 0, - "on": False, - "reachable": True, - }, - "swversion": "100-5.3.5.1122", - "type": "Window covering device", - "uniqueid": "xx:xx:xx:xx:xx:xx:xx:xx-01", -} - async def test_handler_cover(mock_aioresponse, deconz_session, deconz_called_with): """Verify that controlling covers work.""" @@ -113,52 +95,3 @@ async def test_light_cover(deconz_light): cover.remove_callback(mock_callback) assert not cover._callbacks - - -async def test_light_cover_legacy(deconz_light): - """Verify that covers work with older deconz versions.""" - cover = await deconz_light(DATA_LEGACY) - - assert cover.state is False - assert cover.is_open is True - assert cover.lift == 0 - assert cover.tilt is None - - assert cover.reachable is True - - assert cover.deconz_id == "/lights/0" - assert cover.etag == "87269755b9b3a046485fdae8d96b252c" - assert cover.manufacturer == "AXIS" - assert cover.model_id == "Gear" - assert cover.name == "Covering device" - assert cover.software_version == "100-5.3.5.1122" - assert cover.type == "Window covering device" - assert cover.unique_id == "xx:xx:xx:xx:xx:xx:xx:xx-01" - - cover.register_callback(mock_callback := Mock()) - assert cover._callbacks - - event = {"state": {"bri": 50, "on": True}} - cover.update(event) - assert cover.is_open is False - assert cover.lift == 19 - mock_callback.assert_called_once() - assert cover.changed_keys == {"state", "bri", "on"} - - event = {"state": {"bri": 30, "on": False}} - cover.update(event) - assert cover.is_open is True - assert cover.lift == 11 - - # Verify sat (for tilt) works as well - cover.raw["state"]["sat"] = 40 - assert cover.tilt == 15 - - cover.raw["state"]["lift"] = 0 - cover.raw["state"]["tilt"] = 0 - cover.raw["state"]["open"] = True - - assert cover.tilt == 0 - - cover.remove_callback(mock_callback) - assert not cover._callbacks