From a396ee2cb575f1c33990eeee67b67f5b35add8f5 Mon Sep 17 00:00:00 2001 From: Jc2k Date: Wed, 23 Jan 2019 19:44:21 +0000 Subject: [PATCH] Bump homekit==0.12.2 + improve controller reliability (#20325) Sessions were timing out and requiring a HA restart in order to restore functionality. Network disconnects are now handled and sessions will be automatically recovered after they fail. --- .../components/homekit_controller/__init__.py | 14 +++++++------- requirements_all.txt | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index 6fdde7ddd50..17cff702b70 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -13,7 +13,7 @@ from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import call_later -REQUIREMENTS = ['homekit==0.12.0'] +REQUIREMENTS = ['homekit==0.12.2'] DOMAIN = 'homekit_controller' HOMEKIT_DIR = '.homekit' @@ -49,10 +49,6 @@ RETRY_INTERVAL = 60 # seconds PAIRING_FILE = "pairing.json" -class HomeKitConnectionError(ConnectionError): - """Raised when unable to connect to target device.""" - - def get_serial(accessory): """Obtain the serial number of a HomeKit device.""" # pylint: disable=import-error @@ -101,13 +97,14 @@ class HKDevice(): """Handle setup of a HomeKit accessory.""" # pylint: disable=import-error from homekit.model.services import ServicesTypes + from homekit.exceptions import AccessoryDisconnectedError self.pairing.pairing_data['AccessoryIP'] = self.host self.pairing.pairing_data['AccessoryPort'] = self.port try: data = self.pairing.list_accessories_and_characteristics() - except HomeKitConnectionError: + except AccessoryDisconnectedError: call_later( self.hass, RETRY_INTERVAL, lambda _: self.accessory_setup()) return @@ -199,10 +196,13 @@ class HomeKitEntity(Entity): def update(self): """Obtain a HomeKit device's state.""" + # pylint: disable=import-error + from homekit.exceptions import AccessoryDisconnectedError + try: pairing = self._accessory.pairing data = pairing.list_accessories_and_characteristics() - except HomeKitConnectionError: + except AccessoryDisconnectedError: return for accessory in data: if accessory['aid'] != self._aid: diff --git a/requirements_all.txt b/requirements_all.txt index 6ea29d243c9..41c1d081b7e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -526,7 +526,7 @@ home-assistant-frontend==20190121.1 homeassistant-pyozw==0.1.2 # homeassistant.components.homekit_controller -# homekit==0.12.0 +# homekit==0.12.2 # homeassistant.components.homematicip_cloud homematicip==0.10.3