Compare commits

..

1 Commits

Author SHA1 Message Date
Li Shuzhen
1cc5a7aeec
Merge cfb7c01a44 into 57422ddf0d 2025-01-24 10:45:25 +08:00

View File

@ -218,12 +218,7 @@ class Cover(MIoTServiceEntity, CoverEntity):
0: the cover is closed, 100: the cover is fully opened, None: unknown. 0: the cover is closed, 100: the cover is fully opened, None: unknown.
""" """
if self._prop_current_position is None: if self._prop_current_position is None:
# Assume that the current position is the same as the target return None
# position when the current position is not defined in the device's
# MIoT-Spec-V2.
return None if (self._prop_target_position
is None) else self.get_prop_value(
prop=self._prop_target_position)
pos = self.get_prop_value(prop=self._prop_current_position) pos = self.get_prop_value(prop=self._prop_current_position)
if pos is None or self._prop_position_value_range is None: if pos is None or self._prop_position_value_range is None:
return None return None
@ -232,41 +227,27 @@ class Cover(MIoTServiceEntity, CoverEntity):
@property @property
def is_opening(self) -> Optional[bool]: def is_opening(self) -> Optional[bool]:
"""Return if the cover is opening.""" """Return if the cover is opening."""
if self._prop_status and self._prop_status_opening is not None: if self._prop_status is None:
return self.get_prop_value( return None
prop=self._prop_status) == self._prop_status_opening return self.get_prop_value(
# The status is prior to the numerical relationship of the current prop=self._prop_status) == self._prop_status_opening
# position and the target position when determining whether the cover
# is opening.
if (self._prop_target_position and
self.current_cover_position is not None):
return (self.current_cover_position
< self.get_prop_value(prop=self._prop_target_position))
return None
@property @property
def is_closing(self) -> Optional[bool]: def is_closing(self) -> Optional[bool]:
"""Return if the cover is closing.""" """Return if the cover is closing."""
if self._prop_status and self._prop_status_closing is not None: if self._prop_status is None:
return self.get_prop_value( return None
prop=self._prop_status) == self._prop_status_closing return self.get_prop_value(
# The status is prior to the numerical relationship of the current prop=self._prop_status) == self._prop_status_closing
# position and the target position when determining whether the cover
# is closing.
if (self._prop_target_position and
self.current_cover_position is not None):
return (self.current_cover_position
> self.get_prop_value(prop=self._prop_target_position))
return None
@property @property
def is_closed(self) -> Optional[bool]: def is_closed(self) -> Optional[bool]:
"""Return if the cover is closed.""" """Return if the cover is closed."""
if self.current_cover_position is not None: if self._prop_current_position:
return self.current_cover_position == 0 return self.get_prop_value(prop=self._prop_current_position) == 0
# The current position is prior to the status when determining # The current position is prior to the status when determining
# whether the cover is closed. # whether the cover is closed.
if self._prop_status and self._prop_status_closed is not None: return (self.get_prop_value(
return (self.get_prop_value( prop=self._prop_status) == self._prop_status_closed) if (
prop=self._prop_status) == self._prop_status_closed) self._prop_status
return None and self._prop_status_closed is not None) else None