Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy cover #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pydeconz/models/light/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
class TypedCoverState(TypedDict):
"""Cover state type definition."""

bri: int
lift: int
open: bool
sat: int
tilt: int


Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
67 changes: 0 additions & 67 deletions tests/lights/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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