mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-19 00:20:44 +08:00
Compare commits
4 Commits
1cc5a7aeec
...
0c94daa004
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c94daa004 | ||
|
|
3675860526 | ||
|
|
f157f24bc7 | ||
|
|
4d96f75b9a |
@ -218,7 +218,12 @@ 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:
|
||||||
return 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)
|
||||||
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
|
||||||
@ -227,27 +232,41 @@ 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 is None:
|
if self._prop_status and self._prop_status_opening is not None:
|
||||||
return None
|
return self.get_prop_value(
|
||||||
return self.get_prop_value(
|
prop=self._prop_status) == self._prop_status_opening
|
||||||
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
|
||||||
|
|
||||||
@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 is None:
|
if self._prop_status and self._prop_status_closing is not None:
|
||||||
return None
|
return self.get_prop_value(
|
||||||
return self.get_prop_value(
|
prop=self._prop_status) == self._prop_status_closing
|
||||||
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
|
||||||
|
|
||||||
@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._prop_current_position:
|
if self.current_cover_position is not None:
|
||||||
return self.get_prop_value(prop=self._prop_current_position) == 0
|
return self.current_cover_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.
|
||||||
return (self.get_prop_value(
|
if self._prop_status and self._prop_status_closed is not None:
|
||||||
prop=self._prop_status) == self._prop_status_closed) if (
|
return (self.get_prop_value(
|
||||||
self._prop_status
|
prop=self._prop_status) == self._prop_status_closed)
|
||||||
and self._prop_status_closed is not None) else None
|
return None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user