Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions homeassistant/components/bluetooth/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
],
"quality_scale": "internal",
"requirements": [
"bleak==0.22.3",
"bleak-retry-connector==3.9.0",
"bluetooth-adapters==0.21.4",
"bleak==1.0.1",
"bleak-retry-connector==4.0.0",
"bluetooth-adapters==2.0.0",
"bluetooth-auto-recovery==1.5.2",
"bluetooth-data-tools==1.28.2",
"dbus-fast==2.43.0",
"habluetooth==3.49.0"
"habluetooth==4.0.1"
]
}
2 changes: 1 addition & 1 deletion homeassistant/components/eq3btsmart/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"integration_type": "device",
"iot_class": "local_polling",
"loggers": ["eq3btsmart"],
"requirements": ["eq3btsmart==2.1.0", "bleak-esphome==2.16.0"]
"requirements": ["eq3btsmart==2.1.0", "bleak-esphome==3.1.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/esphome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"requirements": [
"aioesphomeapi==34.2.0",
"esphome-dashboard-api==1.3.0",
"bleak-esphome==2.16.0"
"bleak-esphome==3.1.0"
],
"zeroconf": ["_esphomelib._tcp.local."]
}
32 changes: 30 additions & 2 deletions homeassistant/components/keymitt_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,42 @@

from __future__ import annotations

from microbot import MicroBotApiClient
from collections.abc import Generator
from contextlib import contextmanager

import bleak

from homeassistant.components import bluetooth
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_ADDRESS, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady

from .coordinator import MicroBotConfigEntry, MicroBotDataUpdateCoordinator

@contextmanager
def patch_unused_bleak_discover_import() -> Generator[None]:
"""Patch bleak.discover import in microbot. It is unused and was removed in bleak 1.0.0."""

def getattr_bleak(name: str) -> object:
if name == "discover":
return None
raise AttributeError

original_func = bleak.__dict__.get("__getattr__")
bleak.__dict__["__getattr__"] = getattr_bleak
try:
yield
finally:
if original_func is not None:
bleak.__dict__["__getattr__"] = original_func


with patch_unused_bleak_discover_import():
from microbot import MicroBotApiClient

from .coordinator import ( # noqa: E402
MicroBotConfigEntry,
MicroBotDataUpdateCoordinator,
)

PLATFORMS: list[str] = [Platform.SWITCH]

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ audioop-lts==0.2.1
av==13.1.0
awesomeversion==25.5.0
bcrypt==4.3.0
bleak-retry-connector==3.9.0
bleak==0.22.3
bluetooth-adapters==0.21.4
bleak-retry-connector==4.0.0
bleak==1.0.1
bluetooth-adapters==2.0.0
bluetooth-auto-recovery==1.5.2
bluetooth-data-tools==1.28.2
cached-ipaddress==0.10.0
Expand All @@ -34,7 +34,7 @@ dbus-fast==2.43.0
fnv-hash-fast==1.5.0
go2rtc-client==0.2.1
ha-ffmpeg==3.2.2
habluetooth==3.49.0
habluetooth==4.0.1
hass-nabucasa==0.106.0
hassil==2.2.3
home-assistant-bluetooth==1.13.1
Expand Down
10 changes: 5 additions & 5 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions script/hassfest/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"aiohttp": "SemVer",
"attrs": "CalVer",
"awesomeversion": "CalVer",
"bleak": "SemVer",
"grpcio": "SemVer",
"httpx": "SemVer",
"mashumaro": "SemVer",
Expand Down Expand Up @@ -297,10 +298,6 @@
# - domain is the integration domain
# - package is the package (can be transitive) referencing the dependency
# - dependencyX should be the name of the referenced dependency
"bluetooth": {
# https://github.com/hbldh/bleak/pull/1718 (not yet released)
"homeassistant": {"bleak"}
},
"python_script": {
# Security audits are needed for each Python version
"homeassistant": {"restrictedpython"}
Expand Down Expand Up @@ -501,17 +498,9 @@ def get_requirements(integration: Integration, packages: set[str]) -> set[str]:
continue

# Check for restrictive version limits on Python
if (
(requires_python := metadata(package)["Requires-Python"])
and not all(
_is_dependency_version_range_valid(version_part, "SemVer")
for version_part in requires_python.split(",")
)
# "bleak" is a transient dependency of 53 integrations, and we don't
# want to add the whole list to PYTHON_VERSION_CHECK_EXCEPTIONS
# This extra check can be removed when bleak is updated
# https://github.com/hbldh/bleak/pull/1718
and (package in packages or package != "bleak")
if (requires_python := metadata(package)["Requires-Python"]) and not all(
_is_dependency_version_range_valid(version_part, "SemVer")
for version_part in requires_python.split(",")
):
needs_python_version_check_exception = True
integration.add_warning_or_error(
Expand Down
1 change: 0 additions & 1 deletion tests/components/bluemaestro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def make_bluetooth_service_info(
name=name,
address=address,
details={},
rssi=rssi,
),
time=monotonic_time_coarse(),
advertisement=None,
Expand Down
48 changes: 24 additions & 24 deletions tests/components/bluetooth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Tests for the Bluetooth integration."""

from collections.abc import Iterable
from collections.abc import Generator, Iterable
from contextlib import contextmanager
import itertools
import time
from typing import Any
from unittest.mock import MagicMock, patch
from unittest.mock import MagicMock, PropertyMock, patch

from bleak import BleakClient
from bleak.backends.scanner import AdvertisementData, BLEDevice
Expand Down Expand Up @@ -53,7 +53,6 @@

BLE_DEVICE_DEFAULTS = {
"name": None,
"rssi": -127,
"details": None,
}

Expand Down Expand Up @@ -89,7 +88,6 @@ def generate_ble_device(
address: str | None = None,
name: str | None = None,
details: Any | None = None,
rssi: int | None = None,
**kwargs: Any,
) -> BLEDevice:
"""Generate a BLEDevice with defaults."""
Expand All @@ -100,8 +98,6 @@ def generate_ble_device(
new["name"] = name
if details is not None:
new["details"] = details
if rssi is not None:
new["rssi"] = rssi
for key, value in BLE_DEVICE_DEFAULTS.items():
new.setdefault(key, value)
return BLEDevice(**new)
Expand Down Expand Up @@ -215,34 +211,35 @@ def inject_bluetooth_service_info(


@contextmanager
def patch_all_discovered_devices(mock_discovered: list[BLEDevice]) -> None:
def patch_all_discovered_devices(mock_discovered: list[BLEDevice]) -> Generator[None]:
"""Mock all the discovered devices from all the scanners."""
manager = _get_manager()
original_history = {}
scanners = list(
itertools.chain(
manager._connectable_scanners, manager._non_connectable_scanners
)
)
for scanner in scanners:
data = scanner.discovered_devices_and_advertisement_data
original_history[scanner] = data.copy()
data.clear()
if scanners:
data = scanners[0].discovered_devices_and_advertisement_data
data.clear()
data.update(
{device.address: (device, MagicMock()) for device in mock_discovered}
)
yield
for scanner in scanners:
data = scanner.discovered_devices_and_advertisement_data
data.clear()
data.update(original_history[scanner])
if scanners and getattr(scanners[0], "scanner", None):
with patch.object(
scanners[0].scanner.__class__,
"discovered_devices_and_advertisement_data",
new=PropertyMock(
side_effect=[
{
device.address: (device, MagicMock())
for device in mock_discovered
},
]
+ [{}] * (len(scanners))
),
):
yield
else:
yield


@contextmanager
def patch_discovered_devices(mock_discovered: list[BLEDevice]) -> None:
def patch_discovered_devices(mock_discovered: list[BLEDevice]) -> Generator[None]:
"""Mock the combined best path to discovered devices from all the scanners."""
manager = _get_manager()
original_all_history = manager._all_history
Expand Down Expand Up @@ -305,6 +302,9 @@ async def clear_cache(self, *args, **kwargs):
"""Mock clear_cache."""
return True

def set_disconnected_callback(self, callback, **kwargs):
"""Mock set_disconnected_callback."""


class FakeScannerMixin:
def get_discovered_device_advertisement_data(
Expand Down
2 changes: 0 additions & 2 deletions tests/components/bluetooth/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def inject_advertisement(
"44:44:33:11:23:45",
"wohand",
{},
rssi=-100,
)
switchbot_device_adv = generate_advertisement_data(
local_name="wohand",
Expand Down Expand Up @@ -116,7 +115,6 @@ async def test_async_scanner_devices_by_address_non_connectable(
"44:44:33:11:23:45",
"wohand",
{},
rssi=-100,
)
switchbot_device_adv = generate_advertisement_data(
local_name="wohand",
Expand Down
Loading
Loading