Allow template covers to have opening and closing states (#47925)

This commit is contained in:
Brandon Rothweiler 2021-04-09 05:36:02 -04:00 committed by GitHub
parent f396804f54
commit 52e8c7166b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View file

@ -219,6 +219,8 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._optimistic = optimistic or (not state_template and not position_template)
self._tilt_optimistic = tilt_optimistic or not tilt_template
self._position = None
self._is_opening = False
self._is_closing = False
self._tilt_value = None
self._unique_id = unique_id
@ -260,6 +262,9 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._position = 100
else:
self._position = 0
self._is_opening = state == STATE_OPENING
self._is_closing = state == STATE_CLOSING
else:
_LOGGER.error(
"Received invalid cover is_on state: %s. Expected: %s",
@ -319,6 +324,16 @@ class CoverTemplate(TemplateEntity, CoverEntity):
"""Return if the cover is closed."""
return self._position == 0
@property
def is_opening(self):
"""Return if the cover is currently opening."""
return self._is_opening
@property
def is_closing(self):
"""Return if the cover is currently closing."""
return self._is_closing
@property
def current_cover_position(self):
"""Return current position of cover.