Update HAP-python to 2.1.0 (#14528)

This commit is contained in:
cdce8p authored and GitHub committed 2018-05-18 16:32:57 +02:00
1 parent d36996c8f0
commit 12e76ef7c1
8 files changed
+56 -48

No files matched your search

+5 -4
View File
@@ -29,7 +29,7 @@ from .util import show_setup_message, validate_entity_config
TYPES = Registry()
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['HAP-python==2.0.0']
REQUIREMENTS = ['HAP-python==2.1.0']
# #### Driver Status ####
STATUS_READY = 0
@@ -185,7 +185,8 @@ class HomeKit():
ip_addr = self._ip_address or get_local_ip()
path = self.hass.config.path(HOMEKIT_FILE)
self.bridge = HomeBridge(self.hass)
self.driver = HomeDriver(self.bridge, self._port, ip_addr, path)
self.driver = HomeDriver(self.hass, self.bridge, port=self._port,
address=ip_addr, persist_file=path)
def add_bridge_accessory(self, state):
"""Try adding accessory to bridge if configured beforehand."""
@@ -213,8 +214,8 @@ class HomeKit():
self.add_bridge_accessory(state)
self.bridge.set_driver(self.driver)
if not self.bridge.paired:
show_setup_message(self.hass, self.bridge)
if not self.driver.state.paired:
show_setup_message(self.hass, self.driver.state.pincode)
_LOGGER.debug('Driver start')
self.hass.add_job(self.driver.start)
+14 -11
View File
@@ -115,20 +115,23 @@ class HomeBridge(Bridge):
"""Prevent print of pyhap setup message to terminal."""
pass
def add_paired_client(self, client_uuid, client_public):
"""Override super function to dismiss setup message if paired."""
super().add_paired_client(client_uuid, client_public)
dismiss_setup_message(self.hass)
def remove_paired_client(self, client_uuid):
"""Override super function to show setup message if unpaired."""
super().remove_paired_client(client_uuid)
show_setup_message(self.hass, self)
class HomeDriver(AccessoryDriver):
"""Adapter class for AccessoryDriver."""
def __init__(self, *args, **kwargs):
def __init__(self, hass, *args, **kwargs):
"""Initialize a AccessoryDriver object."""
super().__init__(*args, **kwargs)
self.hass = hass
def pair(self, client_uuid, client_public):
"""Override super function to dismiss setup message if paired."""
value = super().pair(client_uuid, client_public)
if value:
dismiss_setup_message(self.hass)
return value
def unpair(self, client_uuid):
"""Override super function to show setup message if unpaired."""
super().unpair(client_uuid)
show_setup_message(self.hass, self.state.pincode)
+2 -2
View File
@@ -38,9 +38,9 @@ def validate_entity_config(values):
return entities
def show_setup_message(hass, bridge):
def show_setup_message(hass, pincode):
"""Display persistent notification with setup information."""
pin = bridge.pincode.decode()
pin = pincode.decode()
_LOGGER.info('Pincode: %s', pin)
message = 'To setup Home Assistant in the Home App, enter the ' \
'following code:\n### {}'.format(pin)