From ef4699375cbbacb7c5fd2dcbffeec00db28edf59 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 29 Jun 2025 00:20:16 +0200 Subject: [PATCH 1/7] Update bleak to 1.0.1 --- .../components/bluetooth/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- script/hassfest/requirements.py | 19 ++++--------------- 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index f212f4bdc1701..e4cd303fd3027 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -15,7 +15,7 @@ ], "quality_scale": "internal", "requirements": [ - "bleak==0.22.3", + "bleak==1.0.1", "bleak-retry-connector==3.9.0", "bluetooth-adapters==0.21.4", "bluetooth-auto-recovery==1.5.2", diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 80fccb1bf78aa..c885297153fc5 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -21,7 +21,7 @@ av==13.1.0 awesomeversion==25.5.0 bcrypt==4.3.0 bleak-retry-connector==3.9.0 -bleak==0.22.3 +bleak==1.0.1 bluetooth-adapters==0.21.4 bluetooth-auto-recovery==1.5.2 bluetooth-data-tools==1.28.1 diff --git a/requirements_all.txt b/requirements_all.txt index afa5256265410..ebf27b38a5316 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -622,7 +622,7 @@ bleak-esphome==2.16.0 bleak-retry-connector==3.9.0 # homeassistant.components.bluetooth -bleak==0.22.3 +bleak==1.0.1 # homeassistant.components.blebox blebox-uniapi==2.5.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 02ed0c645756a..64b88014b4d45 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -556,7 +556,7 @@ bleak-esphome==2.16.0 bleak-retry-connector==3.9.0 # homeassistant.components.bluetooth -bleak==0.22.3 +bleak==1.0.1 # homeassistant.components.blebox blebox-uniapi==2.5.0 diff --git a/script/hassfest/requirements.py b/script/hassfest/requirements.py index a2115ae55915e..f33fc25489d10 100644 --- a/script/hassfest/requirements.py +++ b/script/hassfest/requirements.py @@ -27,6 +27,7 @@ "aiohttp": "SemVer", "attrs": "CalVer", "awesomeversion": "CalVer", + "bleak": "SemVer", "grpcio": "SemVer", "httpx": "SemVer", "mashumaro": "SemVer", @@ -298,10 +299,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"} @@ -502,17 +499,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( From 9bc62575382c9640be0aa7f2fa80e5211e70b457 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:43:29 +0200 Subject: [PATCH 2/7] Fix tests for connect changes --- tests/components/bluetooth/test_models.py | 4 +-- tests/components/bluetooth/test_wrappers.py | 29 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/components/bluetooth/test_models.py b/tests/components/bluetooth/test_models.py index d36741b4d5d0a..ddf254b65a80a 100644 --- a/tests/components/bluetooth/test_models.py +++ b/tests/components/bluetooth/test_models.py @@ -124,7 +124,7 @@ async def async_get_device_by_address(self, address: str) -> BLEDevice | None: "bleak.backends.bluezdbus.client.BleakClientBlueZDBus.is_connected", True ), ): - assert await client.connect() is True + await client.connect() assert client.is_connected is True client.set_disconnected_callback(lambda client: None) await client.disconnect() @@ -215,7 +215,7 @@ async def async_get_device_by_address(self, address: str) -> BLEDevice | None: "bleak.backends.bluezdbus.client.BleakClientBlueZDBus.is_connected", True ), ): - assert await client.connect() is True + await client.connect() assert client.is_connected is True client.set_disconnected_callback(lambda client: None) await client.disconnect() diff --git a/tests/components/bluetooth/test_wrappers.py b/tests/components/bluetooth/test_wrappers.py index bfe7445f614cf..d57d78c283138 100644 --- a/tests/components/bluetooth/test_wrappers.py +++ b/tests/components/bluetooth/test_wrappers.py @@ -92,6 +92,10 @@ class FakeBleakClient(BaseFakeBleakClient): async def connect(self, *args, **kwargs): """Connect.""" + + @property + def is_connected(self): + """Connected.""" return True @@ -100,6 +104,10 @@ class FakeBleakClientFailsToConnect(BaseFakeBleakClient): async def connect(self, *args, **kwargs): """Connect.""" + + @property + def is_connected(self): + """Not connected.""" return False @@ -110,6 +118,11 @@ async def connect(self, *args, **kwargs): """Connect.""" raise ConnectionError("Test exception") + @property + def is_connected(self): + """Not connected.""" + return False + def _generate_ble_device_and_adv_data( interface: str, mac: str, rssi: int @@ -219,7 +232,8 @@ async def test_test_switch_adapters_when_out_of_slots( ): ble_device = hci0_device_advs["00:00:00:00:00:01"][0] client = bleak.BleakClient(ble_device) - assert await client.connect() is True + await client.connect() + assert client.is_connected is True assert allocate_slot_mock.call_count == 1 assert release_slot_mock.call_count == 0 @@ -251,7 +265,8 @@ def _allocate_slot_mock(ble_device: BLEDevice): ): ble_device = hci0_device_advs["00:00:00:00:00:03"][0] client = bleak.BleakClient(ble_device) - assert await client.connect() is True + await client.connect() + assert client.is_connected is True assert release_slot_mock.call_count == 0 cancel_hci0() @@ -278,7 +293,8 @@ async def test_release_slot_on_connect_failure( ): ble_device = hci0_device_advs["00:00:00:00:00:01"][0] client = bleak.BleakClient(ble_device) - assert await client.connect() is False + await client.connect() + assert client.is_connected is False assert allocate_slot_mock.call_count == 1 assert release_slot_mock.call_count == 1 @@ -335,13 +351,18 @@ class FakeBleakClient(BaseFakeBleakClient): async def connect(self, *args, **kwargs): """Connect.""" + + @property + def is_connected(self): + """Connected.""" return True with patch( "habluetooth.wrappers.get_platform_client_backend_type", return_value=FakeBleakClient, ): - assert await client.connect() is True + await client.connect() + assert client.is_connected is True cancel_hci0() cancel_hci1() From b61951ee9a2657305543acfd70cfd9345c49e87c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:43:58 +0200 Subject: [PATCH 3/7] Patch bleak import in microbot --- .../components/keymitt_ble/__init__.py | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/keymitt_ble/__init__.py b/homeassistant/components/keymitt_ble/__init__.py index 0194800685285..0f71519e420fd 100644 --- a/homeassistant/components/keymitt_ble/__init__.py +++ b/homeassistant/components/keymitt_ble/__init__.py @@ -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] From 7786bf176fc6bceafb3946c8f52eb86ab37091c9 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:45:10 +0200 Subject: [PATCH 4/7] Remove BLEDevice rssi argument --- tests/components/bluetooth/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/components/bluetooth/__init__.py b/tests/components/bluetooth/__init__.py index 31d301e2dac8f..19863f39709cd 100644 --- a/tests/components/bluetooth/__init__.py +++ b/tests/components/bluetooth/__init__.py @@ -53,7 +53,6 @@ BLE_DEVICE_DEFAULTS = { "name": None, - "rssi": -127, "details": None, } @@ -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.""" @@ -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) From 3c643e98f1acda00b275d442532afb7050a67842 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 3 Jul 2025 09:54:43 -0500 Subject: [PATCH 5/7] bump some more --- homeassistant/components/bluetooth/manifest.json | 8 ++++---- homeassistant/package_constraints.txt | 8 ++++---- requirements_all.txt | 10 ++++++---- requirements_test_all.txt | 10 ++++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index e4cd303fd3027..cf3ee8e0db9ef 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -16,11 +16,11 @@ "quality_scale": "internal", "requirements": [ "bleak==1.0.1", - "bleak-retry-connector==3.9.0", - "bluetooth-adapters==0.21.4", + "bleak-retry-connector==4.0.0", + "bluetooth-adapters==2.0.0", "bluetooth-auto-recovery==1.5.2", - "bluetooth-data-tools==1.28.1", + "bluetooth-data-tools==1.28.2", "dbus-fast==2.43.0", - "habluetooth==3.49.0" + "habluetooth==4.0.1" ] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index c885297153fc5..0c777d31b4cad 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -20,11 +20,11 @@ audioop-lts==0.2.1 av==13.1.0 awesomeversion==25.5.0 bcrypt==4.3.0 -bleak-retry-connector==3.9.0 +bleak-retry-connector==4.0.0 bleak==1.0.1 -bluetooth-adapters==0.21.4 +bluetooth-adapters==2.0.0 bluetooth-auto-recovery==1.5.2 -bluetooth-data-tools==1.28.1 +bluetooth-data-tools==1.28.2 cached-ipaddress==0.10.0 certifi>=2021.5.30 ciso8601==2.3.2 @@ -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.104.0 hassil==2.2.3 home-assistant-bluetooth==1.13.1 diff --git a/requirements_all.txt b/requirements_all.txt index ebf27b38a5316..3ffed3fc12663 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -619,7 +619,7 @@ bizkaibus==0.1.1 bleak-esphome==2.16.0 # homeassistant.components.bluetooth -bleak-retry-connector==3.9.0 +bleak-retry-connector==4.0.0 # homeassistant.components.bluetooth bleak==1.0.1 @@ -643,17 +643,19 @@ bluemaestro-ble==0.4.1 # bluepy==1.3.0 # homeassistant.components.bluetooth -bluetooth-adapters==0.21.4 +bluetooth-adapters==2.0.0 # homeassistant.components.bluetooth bluetooth-auto-recovery==1.5.2 -# homeassistant.components.bluetooth # homeassistant.components.ld2410_ble # homeassistant.components.led_ble # homeassistant.components.private_ble_device bluetooth-data-tools==1.28.1 +# homeassistant.components.bluetooth +bluetooth-data-tools==1.28.2 + # homeassistant.components.bond bond-async==0.2.1 @@ -1124,7 +1126,7 @@ ha-silabs-firmware-client==0.2.0 habiticalib==0.4.0 # homeassistant.components.bluetooth -habluetooth==3.49.0 +habluetooth==4.0.1 # homeassistant.components.cloud hass-nabucasa==0.104.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 64b88014b4d45..880210978fe5a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -553,7 +553,7 @@ bimmer-connected[china]==0.17.2 bleak-esphome==2.16.0 # homeassistant.components.bluetooth -bleak-retry-connector==3.9.0 +bleak-retry-connector==4.0.0 # homeassistant.components.bluetooth bleak==1.0.1 @@ -574,17 +574,19 @@ bluemaestro-ble==0.4.1 # bluepy==1.3.0 # homeassistant.components.bluetooth -bluetooth-adapters==0.21.4 +bluetooth-adapters==2.0.0 # homeassistant.components.bluetooth bluetooth-auto-recovery==1.5.2 -# homeassistant.components.bluetooth # homeassistant.components.ld2410_ble # homeassistant.components.led_ble # homeassistant.components.private_ble_device bluetooth-data-tools==1.28.1 +# homeassistant.components.bluetooth +bluetooth-data-tools==1.28.2 + # homeassistant.components.bond bond-async==0.2.1 @@ -985,7 +987,7 @@ ha-silabs-firmware-client==0.2.0 habiticalib==0.4.0 # homeassistant.components.bluetooth -habluetooth==3.49.0 +habluetooth==4.0.1 # homeassistant.components.cloud hass-nabucasa==0.104.0 From 4e1e22f1cb92b52ac4022dee30638f5da6991ba9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 3 Jul 2025 09:56:08 -0500 Subject: [PATCH 6/7] bleak-esphome needs to be bumped in same pr --- homeassistant/components/eq3btsmart/manifest.json | 2 +- homeassistant/components/esphome/manifest.json | 2 +- requirements_all.txt | 6 ++---- requirements_test_all.txt | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/eq3btsmart/manifest.json b/homeassistant/components/eq3btsmart/manifest.json index 62128077f2feb..532d0b76da3cd 100644 --- a/homeassistant/components/eq3btsmart/manifest.json +++ b/homeassistant/components/eq3btsmart/manifest.json @@ -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.0.0"] } diff --git a/homeassistant/components/esphome/manifest.json b/homeassistant/components/esphome/manifest.json index 89ffde03a7f46..a916c05ae055d 100644 --- a/homeassistant/components/esphome/manifest.json +++ b/homeassistant/components/esphome/manifest.json @@ -19,7 +19,7 @@ "requirements": [ "aioesphomeapi==33.1.1", "esphome-dashboard-api==1.3.0", - "bleak-esphome==2.16.0" + "bleak-esphome==3.0.0" ], "zeroconf": ["_esphomelib._tcp.local."] } diff --git a/requirements_all.txt b/requirements_all.txt index 5d9e573f32d1d..8b924edda148a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -616,7 +616,7 @@ bizkaibus==0.1.1 # homeassistant.components.eq3btsmart # homeassistant.components.esphome -bleak-esphome==2.16.0 +bleak-esphome==3.0.0 # homeassistant.components.bluetooth bleak-retry-connector==4.0.0 @@ -648,14 +648,12 @@ bluetooth-adapters==2.0.0 # homeassistant.components.bluetooth bluetooth-auto-recovery==1.5.2 +# homeassistant.components.bluetooth # homeassistant.components.ld2410_ble # homeassistant.components.led_ble # homeassistant.components.private_ble_device bluetooth-data-tools==1.28.2 -# homeassistant.components.bluetooth -bluetooth-data-tools==1.28.2 - # homeassistant.components.bond bond-async==0.2.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b39aa3d0fd23b..842e1522ea199 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -550,7 +550,7 @@ bimmer-connected[china]==0.17.2 # homeassistant.components.eq3btsmart # homeassistant.components.esphome -bleak-esphome==2.16.0 +bleak-esphome==3.0.0 # homeassistant.components.bluetooth bleak-retry-connector==4.0.0 @@ -579,14 +579,12 @@ bluetooth-adapters==2.0.0 # homeassistant.components.bluetooth bluetooth-auto-recovery==1.5.2 +# homeassistant.components.bluetooth # homeassistant.components.ld2410_ble # homeassistant.components.led_ble # homeassistant.components.private_ble_device bluetooth-data-tools==1.28.2 -# homeassistant.components.bluetooth -bluetooth-data-tools==1.28.2 - # homeassistant.components.bond bond-async==0.2.1 From 65973d5e1554521b2207e39380359c89d7af9615 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 3 Jul 2025 11:18:35 -0500 Subject: [PATCH 7/7] another bump --- homeassistant/components/eq3btsmart/manifest.json | 2 +- homeassistant/components/esphome/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/eq3btsmart/manifest.json b/homeassistant/components/eq3btsmart/manifest.json index 532d0b76da3cd..472384fdf7d77 100644 --- a/homeassistant/components/eq3btsmart/manifest.json +++ b/homeassistant/components/eq3btsmart/manifest.json @@ -22,5 +22,5 @@ "integration_type": "device", "iot_class": "local_polling", "loggers": ["eq3btsmart"], - "requirements": ["eq3btsmart==2.1.0", "bleak-esphome==3.0.0"] + "requirements": ["eq3btsmart==2.1.0", "bleak-esphome==3.1.0"] } diff --git a/homeassistant/components/esphome/manifest.json b/homeassistant/components/esphome/manifest.json index e97544e358100..17c6bba002de3 100644 --- a/homeassistant/components/esphome/manifest.json +++ b/homeassistant/components/esphome/manifest.json @@ -19,7 +19,7 @@ "requirements": [ "aioesphomeapi==34.1.0", "esphome-dashboard-api==1.3.0", - "bleak-esphome==3.0.0" + "bleak-esphome==3.1.0" ], "zeroconf": ["_esphomelib._tcp.local."] } diff --git a/requirements_all.txt b/requirements_all.txt index db68f37418da1..c6d1a8abce376 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -616,7 +616,7 @@ bizkaibus==0.1.1 # homeassistant.components.eq3btsmart # homeassistant.components.esphome -bleak-esphome==3.0.0 +bleak-esphome==3.1.0 # homeassistant.components.bluetooth bleak-retry-connector==4.0.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f87b1245a4437..1fd34c78a71e0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -550,7 +550,7 @@ bimmer-connected[china]==0.17.2 # homeassistant.components.eq3btsmart # homeassistant.components.esphome -bleak-esphome==3.0.0 +bleak-esphome==3.1.0 # homeassistant.components.bluetooth bleak-retry-connector==4.0.0 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy