Skip to content

Commit

Permalink
Introduced check for operation already in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rospogrigio committed Dec 22, 2021
1 parent 8129311 commit ccb4210
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions custom_components/airbnk_mqtt/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,21 @@ def is_closed(self):

async def async_open_cover(self, **kwargs):
"""Open the cover."""
if self._device.curr_state == LOCK_STATE_OPERATING:
_LOGGER.warning("Operation already in progress: please wait")
raise Exception("Operation already in progress: please wait")
return

_LOGGER.debug("Launching command to open")
await self._device.operateLock(1)

async def async_close_cover(self, **kwargs):
"""Close cover."""
if self._device.curr_state == LOCK_STATE_OPERATING:
_LOGGER.warning("Operation already in progress: please wait")
raise Exception("Operation already in progress: please wait")
return

_LOGGER.debug("Launching command to close")
await self._device.operateLock(2)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/airbnk_mqtt/custom_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def parse_operation_message(self, msg):

async def operateLock(self, lock_dir):
_LOGGER.debug("operateLock called (%s)", lock_dir)
self.curr_state = LOCK_STATE_OPERATING
self.curr_try = 0
self.cmdSent = False
self.curr_state = LOCK_STATE_OPERATING
for callback_func in self._callbacks:
callback_func()

Expand Down
4 changes: 2 additions & 2 deletions custom_components/airbnk_mqtt/tasmota_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ async def async_parse_MQTT_message(self, msg):
callback_func()

async def operateLock(self, lock_dir):
self.curr_try = 0
_LOGGER.debug("operateLock called (%s): attempt %i", lock_dir, self.curr_try)
self.curr_state = LOCK_STATE_OPERATING
self.curr_try = 0
self.frame1sent = False
self.frame2sent = False
self.curr_state = LOCK_STATE_OPERATING
for callback_func in self._callbacks:
callback_func()

Expand Down

0 comments on commit ccb4210

Please sign in to comment.