Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BLE connection state unsubscribe workaround from ESPHome #104674

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 3 additions & 18 deletions homeassistant/components/esphome/bluetooth/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,6 @@ def __str__(self) -> str:
"""Return the string representation of the client."""
return f"ESPHomeClient ({self._description})"

def _unsubscribe_connection_state(self) -> None:
"""Unsubscribe from connection state updates."""
if not self._cancel_connection_state:
return
try:
self._cancel_connection_state()
except (AssertionError, ValueError) as ex:
_LOGGER.debug(
(
"%s: Failed to unsubscribe from connection state (likely"
" connection dropped): %s"
),
self._description,
ex,
)
self._cancel_connection_state = None

def _async_disconnected_cleanup(self) -> None:
"""Clean up on disconnect."""
self.services = BleakGATTServiceCollection() # type: ignore[no-untyped-call]
Expand All @@ -196,7 +179,9 @@ def _async_disconnected_cleanup(self) -> None:
notify_abort()
self._notify_cancels.clear()
self._disconnect_callbacks.discard(self._async_esp_disconnected)
self._unsubscribe_connection_state()
if self._cancel_connection_state:
self._cancel_connection_state()
self._cancel_connection_state = None

def _async_ble_device_disconnected(self) -> None:
"""Handle the BLE device disconnecting from the ESP."""
Expand Down