Fix homekit_controller pairing regression (#19654)

* Fix homekit_controller pairing regression

* Use constant for pairing file name
This commit is contained in:
Jc2k 2018-12-30 19:44:26 +00:00 committed by Charles Garwood
parent 43eaa960e8
commit 855274e354

View File

@ -41,6 +41,8 @@ _LOGGER = logging.getLogger(__name__)
REQUEST_TIMEOUT = 5 # seconds REQUEST_TIMEOUT = 5 # seconds
RETRY_INTERVAL = 60 # seconds RETRY_INTERVAL = 60 # seconds
PAIRING_FILE = "pairing.json"
class HomeKitConnectionError(ConnectionError): class HomeKitConnectionError(ConnectionError):
"""Raised when unable to connect to target device.""" """Raised when unable to connect to target device."""
@ -150,7 +152,7 @@ class HKDevice():
pairing_file = os.path.join( pairing_file = os.path.join(
self.hass.config.path(), self.hass.config.path(),
HOMEKIT_DIR, HOMEKIT_DIR,
'pairing.json' PAIRING_FILE,
) )
self.controller.save_data(pairing_file) self.controller.save_data(pairing_file)
_configurator = self.hass.data[DOMAIN+self.hkid] _configurator = self.hass.data[DOMAIN+self.hkid]
@ -248,7 +250,7 @@ def setup(hass, config):
if not os.path.isdir(data_dir): if not os.path.isdir(data_dir):
os.mkdir(data_dir) os.mkdir(data_dir)
pairing_file = os.path.join(data_dir, 'pairings.json') pairing_file = os.path.join(data_dir, PAIRING_FILE)
if os.path.exists(pairing_file): if os.path.exists(pairing_file):
controller.load_data(pairing_file) controller.load_data(pairing_file)