@@ -120,10 +120,10 @@ def supported_features(self):
120
120
def _current_state (self ) -> str :
121
121
"""Return the current state of the cover."""
122
122
state = self ._current_state_action
123
- curr_pos = self .current_cover_position
123
+ curr_pos = self ._current_cover_position
124
124
# Reset STATE when cover is fully closed or fully opened.
125
- if ( state == STATE_CLOSING and curr_pos == 0 ) or (
126
- state == STATE_OPENING and curr_pos == 100
125
+ if state == STATE_STOPPED or (
126
+ state in ( STATE_CLOSING , STATE_OPENING ) and curr_pos in ( 0 , 100 )
127
127
):
128
128
self ._current_state_action = STATE_STOPPED
129
129
# in case cover moving by set position cmd.
@@ -147,20 +147,20 @@ def current_cover_position(self):
147
147
@property
148
148
def is_opening (self ):
149
149
"""Return if cover is opening."""
150
- state = self ._current_state
151
- return state == STATE_SET_OPENING or state == STATE_OPENING
150
+ return self ._current_state in (STATE_OPENING , STATE_SET_OPENING )
152
151
153
152
@property
154
153
def is_closing (self ):
155
154
"""Return if cover is closing."""
156
- state = self ._current_state
157
- return state == STATE_SET_CLOSING or state == STATE_CLOSING
155
+ return self ._current_state in (STATE_CLOSING , STATE_SET_CLOSING )
158
156
159
157
@property
160
158
def is_closed (self ):
161
159
"""Return if the cover is closed or not."""
162
160
if isinstance (self ._open_cmd , bool ):
163
- return self ._state == self ._close_cmd
161
+ return self ._current_cover_position == 0 and (
162
+ self ._current_state == STATE_STOPPED
163
+ )
164
164
if self ._config [CONF_POSITIONING_MODE ] == MODE_NONE :
165
165
return None
166
166
return self .current_cover_position == 0 and self ._current_state == STATE_STOPPED
@@ -268,7 +268,7 @@ def connection_made(self):
268
268
super ().connection_made ()
269
269
270
270
match self .dp_value (self ._dp_id ):
271
- case str () as i if i .upper ():
271
+ case str () as i if i .isupper ():
272
272
self ._open_cmd = self ._open_cmd .upper ()
273
273
self ._close_cmd = self ._close_cmd .upper ()
274
274
self ._stop_cmd = self ._stop_cmd .upper ()
@@ -283,10 +283,14 @@ def status_updated(self):
283
283
284
284
if self .has_config (CONF_CURRENT_POSITION_DP ):
285
285
curr_pos = self .dp_value (CONF_CURRENT_POSITION_DP )
286
+ if isinstance (curr_pos , bool ):
287
+ curr_pos = 0 if curr_pos else 100
288
+ elif isinstance (curr_pos , str ):
289
+ curr_pos = 0 if curr_pos in ("fully_close" ) else 100
286
290
if self ._position_inverted :
287
- self . _current_cover_position = 100 - curr_pos
288
- else :
289
- self ._current_cover_position = curr_pos
291
+ curr_pos = 100 - curr_pos
292
+
293
+ self ._current_cover_position = curr_pos
290
294
if (
291
295
self ._config [CONF_POSITIONING_MODE ] == MODE_TIME_BASED
292
296
and self ._state != self ._previous_state
@@ -320,8 +324,6 @@ def status_updated(self):
320
324
def update_state (self , action , position = None ):
321
325
"""Update cover current states."""
322
326
state = self ._current_state_action
323
- if isinstance (self ._open_cmd , bool ):
324
- return
325
327
# using Commands.
326
328
if position is None :
327
329
self ._current_state_action = action
0 commit comments