mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Handle HomeKit configuration failure more cleanly (#14041)
* Handle HomeKit configuration failure more cleanly Add support for handling cases where HomeKit configuration fails, and give the user more information about what to do. * Don't consume the exception for a homekit.UnknownError If we get an UnknownError then we should alert the user but also still generate the backtrace so there's actually something for them to file in a bug report.
This commit is contained in:
parent
7f634c6ed0
commit
e4cb3af76d
@ -14,7 +14,7 @@ from homeassistant.components.discovery import SERVICE_HOMEKIT
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['homekit==0.5']
|
||||
REQUIREMENTS = ['homekit==0.6']
|
||||
|
||||
DOMAIN = 'homekit_controller'
|
||||
HOMEKIT_DIR = '.homekit'
|
||||
@ -133,10 +133,31 @@ class HKDevice():
|
||||
import homekit
|
||||
pairing_id = str(uuid.uuid4())
|
||||
code = callback_data.get('code').strip()
|
||||
self.pairing_data = homekit.perform_pair_setup(
|
||||
self.conn, code, pairing_id)
|
||||
try:
|
||||
self.pairing_data = homekit.perform_pair_setup(self.conn, code,
|
||||
pairing_id)
|
||||
except homekit.exception.UnavailableError:
|
||||
error_msg = "This accessory is already paired to another device. \
|
||||
Please reset the accessory and try again."
|
||||
_configurator = self.hass.data[DOMAIN+self.hkid]
|
||||
self.configurator.notify_errors(_configurator, error_msg)
|
||||
return
|
||||
except homekit.exception.AuthenticationError:
|
||||
error_msg = "Incorrect HomeKit code for {}. Please check it and \
|
||||
try again.".format(self.model)
|
||||
_configurator = self.hass.data[DOMAIN+self.hkid]
|
||||
self.configurator.notify_errors(_configurator, error_msg)
|
||||
return
|
||||
except homekit.exception.UnknownError:
|
||||
error_msg = "Received an unknown error. Please file a bug."
|
||||
_configurator = self.hass.data[DOMAIN+self.hkid]
|
||||
self.configurator.notify_errors(_configurator, error_msg)
|
||||
raise
|
||||
|
||||
if self.pairing_data is not None:
|
||||
homekit.save_pairing(self.pairing_file, self.pairing_data)
|
||||
_configurator = self.hass.data[DOMAIN+self.hkid]
|
||||
self.configurator.request_done(_configurator)
|
||||
self.accessory_setup()
|
||||
else:
|
||||
error_msg = "Unable to pair, please try again"
|
||||
|
@ -389,7 +389,7 @@ holidays==0.9.4
|
||||
home-assistant-frontend==20180420.0
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
# homekit==0.5
|
||||
# homekit==0.6
|
||||
|
||||
# homeassistant.components.homematicip_cloud
|
||||
homematicip==0.8
|
||||
|
Loading…
x
Reference in New Issue
Block a user