From 65ca62c991e1f256f435293b5dc7d8a7e6839c01 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 15 Jan 2023 13:17:17 -1000 Subject: [PATCH] Ensure remote bluetooth adapters are loaded before integrations that need them (#85723) --- CODEOWNERS | 2 ++ .../components/airthings_ble/manifest.json | 2 +- homeassistant/components/aranet/manifest.json | 2 +- .../components/bluemaestro/manifest.json | 2 +- .../components/bluetooth_adapters/__init__.py | 20 +++++++++++++++++++ .../bluetooth_adapters/manifest.json | 11 ++++++++++ .../bluetooth_le_tracker/manifest.json | 2 +- homeassistant/components/bthome/manifest.json | 2 +- .../components/eq3btsmart/manifest.json | 2 +- .../components/fjaraskupan/manifest.json | 2 +- .../components/govee_ble/manifest.json | 2 +- .../homekit_controller/manifest.json | 2 +- .../components/ibeacon/manifest.json | 2 +- .../components/inkbird/manifest.json | 2 +- .../components/kegtron/manifest.json | 2 +- .../components/keymitt_ble/manifest.json | 2 +- .../components/ld2410_ble/manifest.json | 2 +- .../components/led_ble/manifest.json | 2 +- homeassistant/components/melnor/manifest.json | 2 +- homeassistant/components/moat/manifest.json | 2 +- homeassistant/components/oralb/manifest.json | 2 +- .../components/qingping/manifest.json | 2 +- .../components/ruuvi_gateway/manifest.json | 1 + .../components/ruuvitag_ble/manifest.json | 2 +- .../components/sensirion_ble/manifest.json | 2 +- .../components/sensorpro/manifest.json | 2 +- .../components/sensorpush/manifest.json | 2 +- homeassistant/components/snooz/manifest.json | 2 +- .../components/switchbot/manifest.json | 2 +- .../components/thermobeacon/manifest.json | 2 +- .../components/thermopro/manifest.json | 2 +- .../components/tilt_ble/manifest.json | 2 +- .../components/xiaomi_ble/manifest.json | 2 +- .../components/yalexs_ble/manifest.json | 2 +- script/hassfest/dependencies.py | 6 ++++++ .../components/bluetooth_adapters/__init__.py | 1 + .../components/bluetooth_adapters/conftest.py | 8 ++++++++ .../bluetooth_adapters/test_init.py | 10 ++++++++++ tests/components/melnor/conftest.py | 7 ++++++- tests/components/ruuvi_gateway/conftest.py | 8 ++++++++ 40 files changed, 103 insertions(+), 31 deletions(-) create mode 100644 homeassistant/components/bluetooth_adapters/__init__.py create mode 100644 homeassistant/components/bluetooth_adapters/manifest.json create mode 100644 tests/components/bluetooth_adapters/__init__.py create mode 100644 tests/components/bluetooth_adapters/conftest.py create mode 100644 tests/components/bluetooth_adapters/test_init.py create mode 100644 tests/components/ruuvi_gateway/conftest.py diff --git a/CODEOWNERS b/CODEOWNERS index fa09e94c8d0..54472d8be20 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -156,6 +156,8 @@ build.json @home-assistant/supervisor /homeassistant/components/bluesound/ @thrawnarn /homeassistant/components/bluetooth/ @bdraco /tests/components/bluetooth/ @bdraco +/homeassistant/components/bluetooth_adapters/ @bdraco +/tests/components/bluetooth_adapters/ @bdraco /homeassistant/components/bmw_connected_drive/ @gerard33 @rikroe /tests/components/bmw_connected_drive/ @gerard33 @rikroe /homeassistant/components/bond/ @bdraco @prystupa @joshs85 @marciogranzotto diff --git a/homeassistant/components/airthings_ble/manifest.json b/homeassistant/components/airthings_ble/manifest.json index 422a51c7187..6321f8e961c 100644 --- a/homeassistant/components/airthings_ble/manifest.json +++ b/homeassistant/components/airthings_ble/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/airthings_ble", "requirements": ["airthings-ble==0.5.3"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@vincegio"], "iot_class": "local_polling", "bluetooth": [ diff --git a/homeassistant/components/aranet/manifest.json b/homeassistant/components/aranet/manifest.json index 6dc5cbe903c..fe450f68755 100644 --- a/homeassistant/components/aranet/manifest.json +++ b/homeassistant/components/aranet/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/aranet", "requirements": ["aranet4==2.1.3"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@aschmitz"], "iot_class": "local_push", "integration_type": "device", diff --git a/homeassistant/components/bluemaestro/manifest.json b/homeassistant/components/bluemaestro/manifest.json index 965b6e440fb..277e02ab488 100644 --- a/homeassistant/components/bluemaestro/manifest.json +++ b/homeassistant/components/bluemaestro/manifest.json @@ -10,7 +10,7 @@ } ], "requirements": ["bluemaestro-ble==0.2.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "iot_class": "local_push" } diff --git a/homeassistant/components/bluetooth_adapters/__init__.py b/homeassistant/components/bluetooth_adapters/__init__.py new file mode 100644 index 00000000000..c2af10d5455 --- /dev/null +++ b/homeassistant/components/bluetooth_adapters/__init__.py @@ -0,0 +1,20 @@ +"""The Bluetooth Adapters integration.""" +from __future__ import annotations + +from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import ConfigType + +DOMAIN = "bluetooth_adapters" + + +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + """Set up Bluetooth Adapters from a config entry. + + This integration is only used as a dependency for other integrations + that need Bluetooth Adapters. + + All integrations that provide Bluetooth Adapters must be listed + in after_dependencies in the manifest.json file to ensure + they are loaded before this integration. + """ + return True diff --git a/homeassistant/components/bluetooth_adapters/manifest.json b/homeassistant/components/bluetooth_adapters/manifest.json new file mode 100644 index 00000000000..a4297871480 --- /dev/null +++ b/homeassistant/components/bluetooth_adapters/manifest.json @@ -0,0 +1,11 @@ +{ + "domain": "bluetooth_adapters", + "name": "Bluetooth Adapters", + "documentation": "https://www.home-assistant.io/integrations/bluetooth_adapters", + "dependencies": ["bluetooth"], + "after_dependencies": ["esphome", "shelly", "ruuvi_gateway"], + "quality_scale": "internal", + "codeowners": ["@bdraco"], + "iot_class": "local_push", + "integration_type": "system" +} diff --git a/homeassistant/components/bluetooth_le_tracker/manifest.json b/homeassistant/components/bluetooth_le_tracker/manifest.json index 6d1d4ba2d4a..c2eeaa10415 100644 --- a/homeassistant/components/bluetooth_le_tracker/manifest.json +++ b/homeassistant/components/bluetooth_le_tracker/manifest.json @@ -2,7 +2,7 @@ "domain": "bluetooth_le_tracker", "name": "Bluetooth LE Tracker", "documentation": "https://www.home-assistant.io/integrations/bluetooth_le_tracker", - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": [], "iot_class": "local_push", "loggers": [] diff --git a/homeassistant/components/bthome/manifest.json b/homeassistant/components/bthome/manifest.json index 9560401226f..b6e35ffdf55 100644 --- a/homeassistant/components/bthome/manifest.json +++ b/homeassistant/components/bthome/manifest.json @@ -18,7 +18,7 @@ } ], "requirements": ["bthome-ble==2.5.0"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@Ernst79"], "iot_class": "local_push" } diff --git a/homeassistant/components/eq3btsmart/manifest.json b/homeassistant/components/eq3btsmart/manifest.json index ade3bc0d912..6db659f61ae 100644 --- a/homeassistant/components/eq3btsmart/manifest.json +++ b/homeassistant/components/eq3btsmart/manifest.json @@ -3,7 +3,7 @@ "name": "eQ-3 Bluetooth Smart Thermostats", "documentation": "https://www.home-assistant.io/integrations/eq3btsmart", "requirements": ["construct==2.10.56", "python-eq3bt==0.2"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@rytilahti"], "iot_class": "local_polling", "loggers": ["bleak", "eq3bt"] diff --git a/homeassistant/components/fjaraskupan/manifest.json b/homeassistant/components/fjaraskupan/manifest.json index 443991b5d70..e1d79887abe 100644 --- a/homeassistant/components/fjaraskupan/manifest.json +++ b/homeassistant/components/fjaraskupan/manifest.json @@ -7,7 +7,7 @@ "codeowners": ["@elupus"], "iot_class": "local_polling", "loggers": ["bleak", "fjaraskupan"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "bluetooth": [ { "connectable": false, diff --git a/homeassistant/components/govee_ble/manifest.json b/homeassistant/components/govee_ble/manifest.json index ad54aa4bc43..2f0bd5bc0c2 100644 --- a/homeassistant/components/govee_ble/manifest.json +++ b/homeassistant/components/govee_ble/manifest.json @@ -74,7 +74,7 @@ } ], "requirements": ["govee-ble==0.21.0"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco", "@PierreAronnax"], "iot_class": "local_push" } diff --git a/homeassistant/components/homekit_controller/manifest.json b/homeassistant/components/homekit_controller/manifest.json index aa343b045ce..9edcba5bf72 100644 --- a/homeassistant/components/homekit_controller/manifest.json +++ b/homeassistant/components/homekit_controller/manifest.json @@ -6,7 +6,7 @@ "requirements": ["aiohomekit==2.4.4"], "zeroconf": ["_hap._tcp.local.", "_hap._udp.local."], "bluetooth": [{ "manufacturer_id": 76, "manufacturer_data_start": [6] }], - "dependencies": ["bluetooth", "zeroconf"], + "dependencies": ["bluetooth_adapters", "zeroconf"], "codeowners": ["@Jc2k", "@bdraco"], "iot_class": "local_push", "loggers": ["aiohomekit", "commentjson"] diff --git a/homeassistant/components/ibeacon/manifest.json b/homeassistant/components/ibeacon/manifest.json index ade53491a4c..86e7b833b69 100644 --- a/homeassistant/components/ibeacon/manifest.json +++ b/homeassistant/components/ibeacon/manifest.json @@ -2,7 +2,7 @@ "domain": "ibeacon", "name": "iBeacon Tracker", "documentation": "https://www.home-assistant.io/integrations/ibeacon", - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "bluetooth": [{ "manufacturer_id": 76, "manufacturer_data_start": [2, 21] }], "requirements": ["ibeacon_ble==1.0.1"], "codeowners": ["@bdraco"], diff --git a/homeassistant/components/inkbird/manifest.json b/homeassistant/components/inkbird/manifest.json index 97234de9d6d..e9984284c72 100644 --- a/homeassistant/components/inkbird/manifest.json +++ b/homeassistant/components/inkbird/manifest.json @@ -11,7 +11,7 @@ { "local_name": "tps", "connectable": false } ], "requirements": ["inkbird-ble==0.5.5"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "iot_class": "local_push" } diff --git a/homeassistant/components/kegtron/manifest.json b/homeassistant/components/kegtron/manifest.json index c3205736226..d64b34e9e60 100644 --- a/homeassistant/components/kegtron/manifest.json +++ b/homeassistant/components/kegtron/manifest.json @@ -10,7 +10,7 @@ } ], "requirements": ["kegtron-ble==0.4.0"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@Ernst79"], "iot_class": "local_push" } diff --git a/homeassistant/components/keymitt_ble/manifest.json b/homeassistant/components/keymitt_ble/manifest.json index 2a21074bb12..b2f7d264311 100644 --- a/homeassistant/components/keymitt_ble/manifest.json +++ b/homeassistant/components/keymitt_ble/manifest.json @@ -14,6 +14,6 @@ "codeowners": ["@spycle"], "requirements": ["PyMicroBot==0.0.8"], "iot_class": "assumed_state", - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "loggers": ["keymitt_ble"] } diff --git a/homeassistant/components/ld2410_ble/manifest.json b/homeassistant/components/ld2410_ble/manifest.json index 566d484c3fb..df7ddff7018 100644 --- a/homeassistant/components/ld2410_ble/manifest.json +++ b/homeassistant/components/ld2410_ble/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/ld2410_ble/", "requirements": ["bluetooth-data-tools==0.3.1", "ld2410-ble==0.1.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@930913"], "bluetooth": [{ "local_name": "HLK-LD2410B_*" }], "integration_type": "device", diff --git a/homeassistant/components/led_ble/manifest.json b/homeassistant/components/led_ble/manifest.json index 9282e0bd8a2..dc40e3855aa 100644 --- a/homeassistant/components/led_ble/manifest.json +++ b/homeassistant/components/led_ble/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/led_ble/", "requirements": ["bluetooth-data-tools==0.3.1", "led-ble==1.0.0"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "bluetooth": [ { "local_name": "LEDnet*" }, diff --git a/homeassistant/components/melnor/manifest.json b/homeassistant/components/melnor/manifest.json index c57549aa647..45d7f82c55b 100644 --- a/homeassistant/components/melnor/manifest.json +++ b/homeassistant/components/melnor/manifest.json @@ -1,11 +1,11 @@ { - "after_dependencies": ["bluetooth"], "bluetooth": [ { "manufacturer_data_start": [89], "manufacturer_id": 13 } ], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@vanstinator"], "config_flow": true, "domain": "melnor", diff --git a/homeassistant/components/moat/manifest.json b/homeassistant/components/moat/manifest.json index f8612cc992f..3a69a9d2cf1 100644 --- a/homeassistant/components/moat/manifest.json +++ b/homeassistant/components/moat/manifest.json @@ -5,7 +5,7 @@ "documentation": "https://www.home-assistant.io/integrations/moat", "bluetooth": [{ "local_name": "Moat_S*", "connectable": false }], "requirements": ["moat-ble==0.1.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "iot_class": "local_push" } diff --git a/homeassistant/components/oralb/manifest.json b/homeassistant/components/oralb/manifest.json index 4ae77cb94cf..a81c684ad95 100644 --- a/homeassistant/components/oralb/manifest.json +++ b/homeassistant/components/oralb/manifest.json @@ -9,7 +9,7 @@ } ], "requirements": ["oralb-ble==0.17.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco", "@conway20"], "iot_class": "local_push" } diff --git a/homeassistant/components/qingping/manifest.json b/homeassistant/components/qingping/manifest.json index 31657280b19..db3db64500f 100644 --- a/homeassistant/components/qingping/manifest.json +++ b/homeassistant/components/qingping/manifest.json @@ -12,7 +12,7 @@ } ], "requirements": ["qingping-ble==0.8.2"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco", "@skgsergio"], "iot_class": "local_push" } diff --git a/homeassistant/components/ruuvi_gateway/manifest.json b/homeassistant/components/ruuvi_gateway/manifest.json index 1a42ebf6c17..468d81fba20 100644 --- a/homeassistant/components/ruuvi_gateway/manifest.json +++ b/homeassistant/components/ruuvi_gateway/manifest.json @@ -4,6 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/ruuvi_gateway", "codeowners": ["@akx"], + "dependencies": ["bluetooth"], "requirements": ["aioruuvigateway==0.0.2"], "iot_class": "local_polling", "dhcp": [ diff --git a/homeassistant/components/ruuvitag_ble/manifest.json b/homeassistant/components/ruuvitag_ble/manifest.json index f7207f685c9..45bc0fba70f 100644 --- a/homeassistant/components/ruuvitag_ble/manifest.json +++ b/homeassistant/components/ruuvitag_ble/manifest.json @@ -14,7 +14,7 @@ } ], "requirements": ["ruuvitag-ble==0.1.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@akx"], "iot_class": "local_push" } diff --git a/homeassistant/components/sensirion_ble/manifest.json b/homeassistant/components/sensirion_ble/manifest.json index a3011639d3e..da95b5828c9 100644 --- a/homeassistant/components/sensirion_ble/manifest.json +++ b/homeassistant/components/sensirion_ble/manifest.json @@ -14,7 +14,7 @@ } ], "requirements": ["sensirion-ble==0.0.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@akx"], "iot_class": "local_push" } diff --git a/homeassistant/components/sensorpro/manifest.json b/homeassistant/components/sensorpro/manifest.json index ba9b8bcf164..07499609133 100644 --- a/homeassistant/components/sensorpro/manifest.json +++ b/homeassistant/components/sensorpro/manifest.json @@ -16,7 +16,7 @@ } ], "requirements": ["sensorpro-ble==0.5.1"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "iot_class": "local_push" } diff --git a/homeassistant/components/sensorpush/manifest.json b/homeassistant/components/sensorpush/manifest.json index d1a370aa9d7..7046837e45f 100644 --- a/homeassistant/components/sensorpush/manifest.json +++ b/homeassistant/components/sensorpush/manifest.json @@ -10,7 +10,7 @@ } ], "requirements": ["sensorpush-ble==1.5.2"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "iot_class": "local_push" } diff --git a/homeassistant/components/snooz/manifest.json b/homeassistant/components/snooz/manifest.json index 91185bcd5b2..56e75e0046e 100644 --- a/homeassistant/components/snooz/manifest.json +++ b/homeassistant/components/snooz/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/snooz", "requirements": ["pysnooz==0.8.3"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@AustinBrunkhorst"], "bluetooth": [ { diff --git a/homeassistant/components/switchbot/manifest.json b/homeassistant/components/switchbot/manifest.json index 05dca82b3f9..a95a97d723e 100644 --- a/homeassistant/components/switchbot/manifest.json +++ b/homeassistant/components/switchbot/manifest.json @@ -4,7 +4,7 @@ "documentation": "https://www.home-assistant.io/integrations/switchbot", "requirements": ["PySwitchbot==0.36.4"], "config_flow": true, - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": [ "@bdraco", "@danielhiversen", diff --git a/homeassistant/components/thermobeacon/manifest.json b/homeassistant/components/thermobeacon/manifest.json index 01e66bbbb94..fbd53c8ab57 100644 --- a/homeassistant/components/thermobeacon/manifest.json +++ b/homeassistant/components/thermobeacon/manifest.json @@ -37,7 +37,7 @@ { "local_name": "ThermoBeacon", "connectable": false } ], "requirements": ["thermobeacon-ble==0.6.0"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "iot_class": "local_push" } diff --git a/homeassistant/components/thermopro/manifest.json b/homeassistant/components/thermopro/manifest.json index dca643a28cf..e9135a44324 100644 --- a/homeassistant/components/thermopro/manifest.json +++ b/homeassistant/components/thermopro/manifest.json @@ -7,7 +7,7 @@ { "local_name": "TP35*", "connectable": false }, { "local_name": "TP39*", "connectable": false } ], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "requirements": ["thermopro-ble==0.4.3"], "codeowners": ["@bdraco"], "iot_class": "local_push" diff --git a/homeassistant/components/tilt_ble/manifest.json b/homeassistant/components/tilt_ble/manifest.json index b201628a7f5..98649dbab28 100644 --- a/homeassistant/components/tilt_ble/manifest.json +++ b/homeassistant/components/tilt_ble/manifest.json @@ -10,7 +10,7 @@ } ], "requirements": ["tilt-ble==0.2.3"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@apt-itude"], "iot_class": "local_push" } diff --git a/homeassistant/components/xiaomi_ble/manifest.json b/homeassistant/components/xiaomi_ble/manifest.json index 93c27027511..4e500979abf 100644 --- a/homeassistant/components/xiaomi_ble/manifest.json +++ b/homeassistant/components/xiaomi_ble/manifest.json @@ -14,7 +14,7 @@ } ], "requirements": ["xiaomi-ble==0.14.3"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@Jc2k", "@Ernst79"], "iot_class": "local_push" } diff --git a/homeassistant/components/yalexs_ble/manifest.json b/homeassistant/components/yalexs_ble/manifest.json index 82d8f0eb228..088f4e3d63c 100644 --- a/homeassistant/components/yalexs_ble/manifest.json +++ b/homeassistant/components/yalexs_ble/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/yalexs_ble", "requirements": ["yalexs-ble==1.12.5"], - "dependencies": ["bluetooth"], + "dependencies": ["bluetooth_adapters"], "codeowners": ["@bdraco"], "bluetooth": [ { diff --git a/script/hassfest/dependencies.py b/script/hassfest/dependencies.py index 9993d5c52a9..cadb007e12c 100644 --- a/script/hassfest/dependencies.py +++ b/script/hassfest/dependencies.py @@ -163,6 +163,12 @@ def calc_allowed_references(integration: Integration) -> set[str]: | set(manifest.get("dependencies", [])) | set(manifest.get("after_dependencies", [])) ) + # bluetooth_adapters is a wrapper to ensure + # that all the integrations that provide bluetooth + # adapters are setup before loading integrations + # that use them. + if "bluetooth_adapters" in allowed_references: + allowed_references.add("bluetooth") # Discovery requirements are ok if referenced in manifest for check_domain, to_check in DISCOVERY_INTEGRATIONS.items(): diff --git a/tests/components/bluetooth_adapters/__init__.py b/tests/components/bluetooth_adapters/__init__.py new file mode 100644 index 00000000000..0681ccff51e --- /dev/null +++ b/tests/components/bluetooth_adapters/__init__.py @@ -0,0 +1 @@ +"""Tests for the Bluetooth Adapters integration.""" diff --git a/tests/components/bluetooth_adapters/conftest.py b/tests/components/bluetooth_adapters/conftest.py new file mode 100644 index 00000000000..9e56959209e --- /dev/null +++ b/tests/components/bluetooth_adapters/conftest.py @@ -0,0 +1,8 @@ +"""bluetooth_adapters session fixtures.""" + +import pytest + + +@pytest.fixture(autouse=True) +def mock_bluetooth(enable_bluetooth): + """Auto mock bluetooth.""" diff --git a/tests/components/bluetooth_adapters/test_init.py b/tests/components/bluetooth_adapters/test_init.py new file mode 100644 index 00000000000..e9874922065 --- /dev/null +++ b/tests/components/bluetooth_adapters/test_init.py @@ -0,0 +1,10 @@ +"""Test the Bluetooth Adapters setup.""" + +from homeassistant.components.bluetooth_adapters import DOMAIN +from homeassistant.core import HomeAssistant +from homeassistant.setup import async_setup_component + + +async def test_setup(hass: HomeAssistant) -> None: + """Ensure we can setup.""" + assert await async_setup_component(hass, DOMAIN, {}) diff --git a/tests/components/melnor/conftest.py b/tests/components/melnor/conftest.py index c06933b7404..2f3c765cfa8 100644 --- a/tests/components/melnor/conftest.py +++ b/tests/components/melnor/conftest.py @@ -1,11 +1,11 @@ """Tests for the melnor integration.""" - from __future__ import annotations from unittest.mock import AsyncMock, patch from bleak.backends.device import BLEDevice from melnor_bluetooth.device import Device +import pytest from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak from homeassistant.components.melnor.const import DOMAIN @@ -52,6 +52,11 @@ FAKE_SERVICE_INFO_2 = BluetoothServiceInfoBleak( ) +@pytest.fixture(autouse=True) +def mock_bluetooth(enable_bluetooth): + """Auto mock bluetooth.""" + + class MockedValve: """Mocked class for a Valve.""" diff --git a/tests/components/ruuvi_gateway/conftest.py b/tests/components/ruuvi_gateway/conftest.py new file mode 100644 index 00000000000..6a57ae00b1e --- /dev/null +++ b/tests/components/ruuvi_gateway/conftest.py @@ -0,0 +1,8 @@ +"""ruuvi_gateway session fixtures.""" + +import pytest + + +@pytest.fixture(autouse=True) +def mock_bluetooth(enable_bluetooth): + """Auto mock bluetooth."""