mirror of
https://github.com/home-assistant/core.git
synced 2026-02-14 23:28:42 +00:00
Catch AccessoryDisconnectedError in homekit pairing (#162466)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -460,6 +460,12 @@ class HomekitControllerFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
except aiohomekit.AccessoryNotFoundError:
|
||||
# Can no longer find the device on the network
|
||||
return self.async_abort(reason="accessory_not_found_error")
|
||||
except aiohomekit.AccessoryDisconnectedError as err:
|
||||
# The accessory has disconnected from the network
|
||||
return self.async_abort(
|
||||
reason="accessory_disconnected_error",
|
||||
description_placeholders={"error": str(err)},
|
||||
)
|
||||
except InsecureSetupCode:
|
||||
errors["pairing_code"] = "insecure_setup_code"
|
||||
except Exception as err:
|
||||
@@ -490,6 +496,12 @@ class HomekitControllerFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
except aiohomekit.AccessoryNotFoundError:
|
||||
# Can no longer find the device on the network
|
||||
return self.async_abort(reason="accessory_not_found_error")
|
||||
except aiohomekit.AccessoryDisconnectedError as err:
|
||||
# The accessory has disconnected from the network
|
||||
return self.async_abort(
|
||||
reason="accessory_disconnected_error",
|
||||
description_placeholders={"error": str(err)},
|
||||
)
|
||||
except IndexError:
|
||||
# TLV error, usually not in pairing mode
|
||||
_LOGGER.exception("Pairing communication failed")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"config": {
|
||||
"abort": {
|
||||
"accessory_disconnected_error": "A connectivity error occurred while attempting to pair with this device.\n\n{error}",
|
||||
"accessory_not_found_error": "Cannot add pairing as device can no longer be found.",
|
||||
"already_configured": "Accessory is already configured with this controller.",
|
||||
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
|
||||
|
||||
@@ -34,6 +34,7 @@ PAIRING_START_FORM_ERRORS = [
|
||||
]
|
||||
|
||||
PAIRING_START_ABORT_ERRORS = [
|
||||
(aiohomekit.AccessoryDisconnectedError, "accessory_disconnected_error"),
|
||||
(aiohomekit.AccessoryNotFoundError, "accessory_not_found_error"),
|
||||
(aiohomekit.UnavailableError, "already_paired"),
|
||||
]
|
||||
@@ -53,7 +54,8 @@ PAIRING_FINISH_FORM_ERRORS = [
|
||||
]
|
||||
|
||||
PAIRING_FINISH_ABORT_ERRORS = [
|
||||
(aiohomekit.AccessoryNotFoundError, "accessory_not_found_error")
|
||||
(aiohomekit.AccessoryDisconnectedError, "accessory_disconnected_error"),
|
||||
(aiohomekit.AccessoryNotFoundError, "accessory_not_found_error"),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user