Skip to content

Commit

Permalink
Remove workaround to populate missing handles (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jul 17, 2023
1 parent 5c61085 commit 8b5144f
Showing 1 changed file with 1 addition and 19 deletions.
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

0 comments on commit 8b5144f

Please sign in to comment.