mirror of
https://github.com/home-assistant/core.git
synced 2025-08-08 07:05:07 +02:00
Relocate Bluetooth manager to habluetooth library
This commit is contained in:
@@ -2,13 +2,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from typing import TYPE_CHECKING, Any
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from bleak.backends.device import BLEDevice
|
|
||||||
from bleak.backends.scanner import AdvertisementData
|
|
||||||
from bluetooth_adapters import DiscoveredDeviceAdvertisementData
|
from bluetooth_adapters import DiscoveredDeviceAdvertisementData
|
||||||
from habluetooth import BaseHaRemoteScanner, BaseHaScanner, HaBluetoothConnector
|
from habluetooth import BaseHaRemoteScanner, HaBluetoothConnector
|
||||||
from home_assistant_bluetooth import BluetoothServiceInfoBleak
|
from home_assistant_bluetooth import BluetoothServiceInfoBleak
|
||||||
|
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
@@ -19,16 +16,10 @@ from homeassistant.core import (
|
|||||||
callback as hass_callback,
|
callback as hass_callback,
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import models
|
from .const import DATA_MANAGER
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
@dataclass(slots=True)
|
from .manager import HomeAssistantBluetoothManager
|
||||||
class BluetoothScannerDevice:
|
|
||||||
"""Data for a bluetooth device from a given scanner."""
|
|
||||||
|
|
||||||
scanner: BaseHaScanner
|
|
||||||
ble_device: BLEDevice
|
|
||||||
advertisement: AdvertisementData
|
|
||||||
|
|
||||||
|
|
||||||
class HomeAssistantRemoteScanner(BaseHaRemoteScanner):
|
class HomeAssistantRemoteScanner(BaseHaRemoteScanner):
|
||||||
@@ -55,8 +46,8 @@ class HomeAssistantRemoteScanner(BaseHaRemoteScanner):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
assert models.MANAGER is not None
|
manager: HomeAssistantBluetoothManager = hass.data[DATA_MANAGER]
|
||||||
self._storage = models.MANAGER.storage
|
self._storage = manager.storage
|
||||||
self._cancel_stop: CALLBACK_TYPE | None = None
|
self._cancel_stop: CALLBACK_TYPE | None = None
|
||||||
super().__init__(scanner_id, name, new_info_callback, connector, connectable)
|
super().__init__(scanner_id, name, new_info_callback, connector, connectable)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user