Skip to content

Commit

Permalink
Fix automatically connecting multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
LennP committed Mar 21, 2024
1 parent b426d4f commit e730bbd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions motionblindsble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,11 @@ def _notification_callback(
def _disconnect_callback(self, _: BleakClient) -> None:
"""Handle a BleakClient disconnect."""
_LOGGER.debug("(%s) Disconnected", self.ble_device.address)
self.update_connection(MotionConnectionType.DISCONNECTED)
self.update_calibration(None)
self.update_running(None)
self.update_position(None, None)
self.update_speed(None)
self.update_connection(MotionConnectionType.DISCONNECTED)
self._current_bleak_client = None
if self._permanent_connection:
if self._ha_create_task:
Expand All @@ -602,10 +602,11 @@ def _disconnect_callback(self, _: BleakClient) -> None:
self.ble_device.address,
)
self._ha_create_task(target=self.connect()) # type: ignore[call-arg]
_LOGGER.debug(
"(%s) Automatically reconnecting", self.ble_device.address
)
get_event_loop().create_task(self.connect())
else:
_LOGGER.debug(
"(%s) Automatically reconnecting", self.ble_device.address
)
get_event_loop().create_task(self.connect())

async def connect(
self, disable_callbacks: list[MotionCallback] | None = None
Expand Down

0 comments on commit e730bbd

Please sign in to comment.