Add a new constant for multiple bluetooth watchdog failure hits (#77081)
This commit is contained in:
parent
0bd4973134
commit
2d0b11f18e
1 changed files with 16 additions and 3 deletions
|
@ -56,6 +56,15 @@ SCANNING_MODE_TO_BLEAK = {
|
||||||
BluetoothScanningMode.PASSIVE: "passive",
|
BluetoothScanningMode.PASSIVE: "passive",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The minimum number of seconds to know
|
||||||
|
# the adapter has not had advertisements
|
||||||
|
# and we already tried to restart the scanner
|
||||||
|
# without success when the first time the watch
|
||||||
|
# dog hit the failure path.
|
||||||
|
SCANNER_WATCHDOG_MULTIPLE = (
|
||||||
|
SCANNER_WATCHDOG_TIMEOUT + SCANNER_WATCHDOG_INTERVAL.total_seconds()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ScannerStartError(HomeAssistantError):
|
class ScannerStartError(HomeAssistantError):
|
||||||
"""Error to indicate that the scanner failed to start."""
|
"""Error to indicate that the scanner failed to start."""
|
||||||
|
@ -276,9 +285,13 @@ class HaScanner:
|
||||||
# Stop the scanner but not the watchdog
|
# Stop the scanner but not the watchdog
|
||||||
# since we want to try again later if it's still quiet
|
# since we want to try again later if it's still quiet
|
||||||
await self._async_stop_scanner()
|
await self._async_stop_scanner()
|
||||||
if self._start_time == self._last_detection or (
|
# If there have not been any valid advertisements,
|
||||||
time_since_last_detection
|
# or the watchdog has hit the failure path multiple times,
|
||||||
) > (SCANNER_WATCHDOG_TIMEOUT + SCANNER_WATCHDOG_INTERVAL.total_seconds()):
|
# do the reset.
|
||||||
|
if (
|
||||||
|
self._start_time == self._last_detection
|
||||||
|
or time_since_last_detection > SCANNER_WATCHDOG_MULTIPLE
|
||||||
|
):
|
||||||
await self._async_reset_adapter()
|
await self._async_reset_adapter()
|
||||||
try:
|
try:
|
||||||
await self._async_start()
|
await self._async_start()
|
||||||
|
|
Loading…
Add table
Reference in a new issue