Skip to content

Commit 11609df

Browse files
committed
Remove _is_completely_open property and init _state with None
- We init `_state` with None and let the `_determine_cover_state` function populate the value from current positions - Ensures all lines are coverable by tests
1 parent 1a2173f commit 11609df

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

zha/application/platforms/cover/__init__.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(
103103
self._lift_transition_timer: asyncio.TimerHandle | None = None
104104
self._tilt_transition_timer: asyncio.TimerHandle | None = None
105105

106-
self._state: CoverState | None = CoverState.OPEN
106+
self._state: CoverState | None = None
107107
self._determine_cover_state(refresh=True)
108108

109109
def recompute_capabilities(self) -> None:
@@ -163,7 +163,12 @@ def restore_external_state_attributes(
163163
return
164164
if state == CoverState.CLOSING and self.is_closed:
165165
return
166-
if state == CoverState.OPENING and self._is_completely_open:
166+
if (
167+
state == CoverState.OPENING
168+
and self._state == CoverState.OPEN
169+
and self.current_cover_position in (100, None)
170+
and self.current_cover_tilt_position in (100, None)
171+
):
167172
return
168173

169174
self._state = state
@@ -244,17 +249,6 @@ def _previous_cover_tilt_position(self) -> int | None:
244249
"""Return the previous tilt position of ZHA cover."""
245250
return self._tilt_position_history[0]
246251

247-
@property
248-
def _is_completely_open(self) -> bool | None:
249-
"""Return True if the cover is completely open."""
250-
if not self._state:
251-
return None
252-
return (
253-
self._state == CoverState.OPEN
254-
and self.current_cover_position in (100, None)
255-
and self.current_cover_tilt_position in (100, None)
256-
)
257-
258252
@staticmethod
259253
def _determine_state(
260254
current: int | None,

0 commit comments

Comments
 (0)