@@ -170,33 +170,33 @@ async def _send_state_command(
170
170
f"Cannot change state of device type: { self .device_type } "
171
171
)
172
172
173
- async with self ._send_command_lock :
174
- # If currently there is a wait_for_state task running,
175
- # then wait until it completes first.
176
- if self ._wait_for_state_task is not None :
177
- # Return wait task if we're currently waiting for same task to be completed
178
- if self .state == intermediate_state and not wait_for_state :
179
- _LOGGER .debug (
180
- "Command %s for %s was already send, returning wait task for it instead" ,
181
- command ,
182
- self .name ,
183
- )
184
- return self ._wait_for_state_task
185
-
173
+ # If currently there is a wait_for_state task running,
174
+ # then wait until it completes first.
175
+ if self ._wait_for_state_task is not None :
176
+ # Return wait task if we're currently waiting for same task to be completed
177
+ if self .state == intermediate_state and not wait_for_state :
186
178
_LOGGER .debug (
187
- "Another command for %s is still in progress, waiting for it to complete first before issuing command %s" ,
188
- self .name ,
179
+ "Command %s for %s was already send, returning wait task for it instead" ,
189
180
command ,
181
+ self .name ,
190
182
)
191
- await self ._wait_for_state_task
183
+ return self ._wait_for_state_task
192
184
193
- # We return true if state is already closed.
194
- if self .state == to_state :
195
- _LOGGER .debug (
196
- "Device %s is in state %s, nothing to do." , self .name , to_state
197
- )
198
- return True
185
+ _LOGGER .debug (
186
+ "Another command for %s is still in progress, waiting for it to complete first before issuing command %s" ,
187
+ self .name ,
188
+ command ,
189
+ )
190
+ await self ._wait_for_state_task
191
+
192
+ # We return true if state is already closed.
193
+ if self .state == to_state :
194
+ _LOGGER .debug (
195
+ "Device %s is in state %s, nothing to do." , self .name , to_state
196
+ )
197
+ return True
199
198
199
+ async with self ._send_command_lock :
200
200
_LOGGER .debug ("Sending command %s for %s" , command , self .name )
201
201
await self .account .api .request (
202
202
method = "put" ,
0 commit comments