Skip to content

Commit

Permalink
↕️ improve for cover (#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
billsq authored Oct 12, 2023
1 parent 3038248 commit bfcf402
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions custom_components/xiaomi_miot/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,8 @@ async def async_added_to_hass(self):

self._motor_reverse = self.custom_config_bool('motor_reverse', False)
self._position_reverse = self.custom_config_bool('position_reverse', self._motor_reverse)
self._open_texts = [
*(self.custom_config_list('open_texts') or []),
'Opening', 'Opened', 'Open', 'Up', 'Rising', 'Risen', 'Rise',
]
self._close_texts = [
*(self.custom_config_list('close_texts') or []),
'Closing', 'Closed', 'Close', 'Down', 'Falling', 'Descent',
]
self._open_texts = self.custom_config_list('open_texts', ['Opening', 'Opened', 'Open', 'Up', 'Rising', 'Risen', 'Rise'])
self._close_texts = self.custom_config_list('close_texts', ['Closing', 'Closed', 'Close', 'Down', 'Falling', 'Descent'])
if self._motor_reverse:
self._open_texts, self._close_texts = self._close_texts, self._open_texts

Expand Down Expand Up @@ -170,6 +164,11 @@ def current_cover_position(self):
elif range_max != 100:
pos = cur / range_max * 100
if pos < 0:
# If the motor controller is stopped, generate fake middle position
if self._prop_status:
sta = int(self._prop_status.from_dict(self._state_attrs) or -1)
if sta in self._prop_status.list_search('Stopped'):
return 50
return None
dev = int(self.custom_config_integer('deviated_position', 1) or 0)
if pos <= dev:
Expand Down

0 comments on commit bfcf402

Please sign in to comment.