mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Move imports in skybeacon component (#28099)
This commit is contained in:
parent
1111e150f4
commit
d9cb9601aa
@ -3,6 +3,9 @@ import logging
|
|||||||
import threading
|
import threading
|
||||||
from uuid import UUID
|
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
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
@ -132,13 +135,8 @@ class Monitor(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Thread that keeps connection alive."""
|
"""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)
|
cached_char = Characteristic(BLE_TEMP_UUID, BLE_TEMP_HANDLE)
|
||||||
adapter = pygatt.backends.GATTToolBackend()
|
adapter = GATTToolBackend()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
_LOGGER.debug("Connecting to %s", self.name)
|
_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
|
# Seems only one connection can be initiated at a time
|
||||||
with CONNECT_LOCK:
|
with CONNECT_LOCK:
|
||||||
device = adapter.connect(
|
device = adapter.connect(
|
||||||
self.mac, CONNECT_TIMEOUT, pygatt.BLEAddressType.random
|
self.mac, CONNECT_TIMEOUT, BLEAddressType.random
|
||||||
)
|
)
|
||||||
if SKIP_HANDLE_LOOKUP:
|
if SKIP_HANDLE_LOOKUP:
|
||||||
# HACK: inject handle mapping collected offline
|
# HACK: inject handle mapping collected offline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user