mirror of
https://github.com/home-assistant/core.git
synced 2026-09-02 11:31:45 +01:00
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
19 lines
525 B
Python
19 lines
525 B
Python
"""bluetooth usage utility to handle multiple instances."""
|
|
from __future__ import annotations
|
|
|
|
import bleak
|
|
|
|
from .models import HaBleakScannerWrapper
|
|
|
|
ORIGINAL_BLEAK_SCANNER = bleak.BleakScanner
|
|
|
|
|
|
def install_multiple_bleak_catcher() -> None:
|
|
"""Wrap the bleak classes to return the shared instance if multiple instances are detected."""
|
|
bleak.BleakScanner = HaBleakScannerWrapper
|
|
|
|
|
|
def uninstall_multiple_bleak_catcher() -> None:
|
|
"""Unwrap the bleak classes."""
|
|
bleak.BleakScanner = ORIGINAL_BLEAK_SCANNER
|