Move imports in skybeacon component (#28099)

This commit is contained in:
Diefferson Koderer Môro 2019-10-22 05:31:58 +00:00 committed by Paulus Schoutsen
parent 1111e150f4
commit d9cb9601aa

View file

@ -3,6 +3,9 @@ import logging
import threading
from uuid import UUID
from pygatt import BLEAddressType
from pygatt.backends import Characteristic, GATTToolBackend
from pygatt.exceptions import BLEError, NotConnectedError, NotificationTimeout
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
@ -132,13 +135,8 @@ class Monitor(threading.Thread):
def run(self):
"""Thread that keeps connection alive."""
# pylint: disable=import-error
import pygatt
from pygatt.backends import Characteristic
from pygatt.exceptions import BLEError, NotConnectedError, NotificationTimeout
cached_char = Characteristic(BLE_TEMP_UUID, BLE_TEMP_HANDLE)
adapter = pygatt.backends.GATTToolBackend()
adapter = GATTToolBackend()
while True:
try:
_LOGGER.debug("Connecting to %s", self.name)
@ -147,7 +145,7 @@ class Monitor(threading.Thread):
# Seems only one connection can be initiated at a time
with CONNECT_LOCK:
device = adapter.connect(
self.mac, CONNECT_TIMEOUT, pygatt.BLEAddressType.random
self.mac, CONNECT_TIMEOUT, BLEAddressType.random
)
if SKIP_HANDLE_LOOKUP:
# HACK: inject handle mapping collected offline