Skip to content

Commit

Permalink
fix: Handling retired or changed scanners (#360)
Browse files Browse the repository at this point in the history
- Refactor _refresh_scanners to be more efficient, and to handle the case where a scanner still exists but is no longer a scanner.
- Refactor coordinator.init() to move callbacks out into class methods.
- Tamed down lots of debug logging
- Altered self.last_config_entry_update to use MONOTONIC_TIME(), and changed cooldown to a const of 10 seconds, and included check for parallel save tasks.
- Removed assert that excluded scanners from area-by-mindist
  • Loading branch information
agittins authored Nov 7, 2024
1 parent 2dd6b38 commit eee3e0e
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 205 deletions.
14 changes: 9 additions & 5 deletions custom_components/bermuda/bermuda_device_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ def update_advertisement(self, scandata: BluetoothScannerDevice):
# I want to know if it does.
# AJG 2024-01-11: This does happen. Looks like maybe apple devices?
# Changing from warning to debug to quiet users' logs.
_LOGGER.debug(
"Device changed TX-POWER! That was unexpected: %s %sdB",
self.parent_device_address,
scandata.advertisement.tx_power,
)
# Also happens with esphome set with long beacon interval tx, as it alternates
# between sending some generic advert and the iBeacon advert. ie, it's bogus for that
# case.
# _LOGGER.debug(
# "Device changed TX-POWER! That was unexpected: %s %sdB",
# self.parent_device_address,
# scandata.advertisement.tx_power,
# )
pass
self.tx_power = scandata.advertisement.tx_power

# Track each advertisement element as or if they change.
Expand Down
2 changes: 2 additions & 0 deletions custom_components/bermuda/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
PRUNE_TIME_DEFAULT = 259200 # Max age of regular device entries (3days)
PRUNE_TIME_IRK = 3600 # Resolvable Private addresses change often, prune regularly (1h)

SAVEOUT_COOLDOWN = 10 # seconds to delay before re-trying config entry save.

DOCS = {}


Expand Down
Loading

0 comments on commit eee3e0e

Please sign in to comment.