mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix HKC exceptions during BLE startup not being caught (#80882)
This commit is contained in:
parent
9978296ae2
commit
a7610909de
@ -35,6 +35,7 @@ from .const import (
|
|||||||
IDENTIFIER_LEGACY_ACCESSORY_ID,
|
IDENTIFIER_LEGACY_ACCESSORY_ID,
|
||||||
IDENTIFIER_LEGACY_SERIAL_NUMBER,
|
IDENTIFIER_LEGACY_SERIAL_NUMBER,
|
||||||
IDENTIFIER_SERIAL_NUMBER,
|
IDENTIFIER_SERIAL_NUMBER,
|
||||||
|
STARTUP_EXCEPTIONS,
|
||||||
)
|
)
|
||||||
from .device_trigger import async_fire_triggers, async_setup_triggers_for_entry
|
from .device_trigger import async_fire_triggers, async_setup_triggers_for_entry
|
||||||
|
|
||||||
@ -187,11 +188,12 @@ class HKDevice:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
await self.pairing.async_populate_accessories_state(force_update=True)
|
await self.pairing.async_populate_accessories_state(force_update=True)
|
||||||
except (asyncio.TimeoutError, AccessoryNotFoundError):
|
except STARTUP_EXCEPTIONS as ex:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Failed to populate BLE accessory state for %s, accessory may be sleeping"
|
"Failed to populate BLE accessory state for %s, accessory may be sleeping"
|
||||||
" and will be retried the next time it advertises",
|
" and will be retried the next time it advertises: %s",
|
||||||
self.config_entry.title,
|
self.config_entry.title,
|
||||||
|
ex,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_setup(self) -> None:
|
async def async_setup(self) -> None:
|
||||||
@ -220,7 +222,7 @@ class HKDevice:
|
|||||||
# BLE devices may sleep and we can't force a connection
|
# BLE devices may sleep and we can't force a connection
|
||||||
raise
|
raise
|
||||||
entry.async_on_unload(
|
entry.async_on_unload(
|
||||||
self.hass.bus.async_listen_once(
|
self.hass.bus.async_listen(
|
||||||
EVENT_HOMEASSISTANT_STARTED,
|
EVENT_HOMEASSISTANT_STARTED,
|
||||||
self._async_retry_populate_ble_accessory_state,
|
self._async_retry_populate_ble_accessory_state,
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
"""Constants for the homekit_controller component."""
|
"""Constants for the homekit_controller component."""
|
||||||
|
import asyncio
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
|
from aiohomekit.exceptions import (
|
||||||
|
AccessoryDisconnectedError,
|
||||||
|
AccessoryNotFoundError,
|
||||||
|
EncryptionError,
|
||||||
|
)
|
||||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
|
|
||||||
@ -94,3 +100,10 @@ CHARACTERISTIC_PLATFORMS = {
|
|||||||
|
|
||||||
# Device classes
|
# Device classes
|
||||||
DEVICE_CLASS_ECOBEE_MODE: Final = "homekit_controller__ecobee_mode"
|
DEVICE_CLASS_ECOBEE_MODE: Final = "homekit_controller__ecobee_mode"
|
||||||
|
|
||||||
|
STARTUP_EXCEPTIONS = (
|
||||||
|
asyncio.TimeoutError,
|
||||||
|
AccessoryNotFoundError,
|
||||||
|
EncryptionError,
|
||||||
|
AccessoryDisconnectedError,
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user