Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Commit

Permalink
Additional cover status fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ollo69 committed Jul 4, 2020
1 parent acd685f commit e1a1e36
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions custom_components/tuya_custom/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, tuya, platform):
super().__init__(tuya, platform)
self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id())
self._was_closing = False
self._was_opening = False

@property
def supported_features(self):
Expand All @@ -72,6 +73,7 @@ def is_opening(self):
"""Return if the cover is opening or not."""
state = self._tuya.state()
if state == 1:
self._was_opening = True
self._was_closing = False
return True
return False
Expand All @@ -81,6 +83,7 @@ def is_closing(self):
"""Return if the cover is closing or not."""
state = self._tuya.state()
if state == 2:
self._was_opening = False
self._was_closing = True
return True
return False
Expand All @@ -89,13 +92,15 @@ def is_closing(self):
def is_closed(self):
"""Return if the cover is closed or not."""
state = self._tuya.state()
return state != 2 and self._was_closing
# state = self._tuya.state()
if state != 2 and self._was_closing:
return True
if state != 1 and self._was_opening:
return False
# if state == 1:
# return False
# if state == 2:
# return True
# return None
return None

def open_cover(self, **kwargs):
"""Open the cover."""
Expand All @@ -107,6 +112,7 @@ def close_cover(self, **kwargs):

def stop_cover(self, **kwargs):
"""Stop the cover."""
if not self.is_closed:
if self.is_closed is None:
self._was_opening = False
self._was_closing = False
self._tuya.stop_cover()

0 comments on commit e1a1e36

Please sign in to comment.