mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-17 15:41:15 +08:00
Compare commits
1 Commits
0c94daa004
...
1cc5a7aeec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cc5a7aeec |
@ -218,12 +218,7 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
0: the cover is closed, 100: the cover is fully opened, None: unknown.
|
||||
"""
|
||||
if self._prop_current_position is None:
|
||||
# Assume that the current position is the same as the target
|
||||
# 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)
|
||||
return None
|
||||
pos = self.get_prop_value(prop=self._prop_current_position)
|
||||
if pos is None or self._prop_position_value_range is None:
|
||||
return None
|
||||
@ -232,41 +227,27 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
@property
|
||||
def is_opening(self) -> Optional[bool]:
|
||||
"""Return if the cover is opening."""
|
||||
if self._prop_status and self._prop_status_opening is not None:
|
||||
return self.get_prop_value(
|
||||
prop=self._prop_status) == self._prop_status_opening
|
||||
# The status is prior to the numerical relationship of the current
|
||||
# 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
|
||||
if self._prop_status is None:
|
||||
return None
|
||||
return self.get_prop_value(
|
||||
prop=self._prop_status) == self._prop_status_opening
|
||||
|
||||
@property
|
||||
def is_closing(self) -> Optional[bool]:
|
||||
"""Return if the cover is closing."""
|
||||
if self._prop_status and self._prop_status_closing is not None:
|
||||
return self.get_prop_value(
|
||||
prop=self._prop_status) == self._prop_status_closing
|
||||
# The status is prior to the numerical relationship of the current
|
||||
# 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
|
||||
if self._prop_status is None:
|
||||
return None
|
||||
return self.get_prop_value(
|
||||
prop=self._prop_status) == self._prop_status_closing
|
||||
|
||||
@property
|
||||
def is_closed(self) -> Optional[bool]:
|
||||
"""Return if the cover is closed."""
|
||||
if self.current_cover_position is not None:
|
||||
return self.current_cover_position == 0
|
||||
if self._prop_current_position:
|
||||
return self.get_prop_value(prop=self._prop_current_position) == 0
|
||||
# The current position is prior to the status when determining
|
||||
# whether the cover is closed.
|
||||
if self._prop_status and self._prop_status_closed is not None:
|
||||
return (self.get_prop_value(
|
||||
prop=self._prop_status) == self._prop_status_closed)
|
||||
return None
|
||||
return (self.get_prop_value(
|
||||
prop=self._prop_status) == self._prop_status_closed) if (
|
||||
self._prop_status
|
||||
and self._prop_status_closed is not None) else None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user