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 workaround to populate missing handles #301

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions aiohomekit/controller/ble/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,20 +1073,6 @@ async def _async_populate_accessories_state(
if self._restore_pending:
await self._async_restore_subscriptions()

def _all_handles_are_missing(self) -> bool:
"""Check if any characteristic has a handle.

Older code did not save the handle, so if we have no handles
we need to re-fetch the gatt database.
"""
if not self.accessories.accessories:
return True
for service in self.accessories.aid(BLE_AID).services:
for char in service.characteristics:
if char.handle is not None:
return False
return True

async def _populate_accessories_and_characteristics(
self, force_update: bool = False, attempts: int | None = None
) -> None:
Expand Down Expand Up @@ -1121,11 +1107,7 @@ async def _populate_accessories_and_characteristics(
if self.description:
config_changed = self.config_num != self.description.config_num

if (
not self.accessories
or config_changed
or self._all_handles_are_missing()
):
if not self.accessories or config_changed:
logger.debug(
"%s: Fetching gatt database because, cached_config_num: %s, adv config_num: %s",
self.name,
Expand Down
Loading