From 17d1c0733d935b8c9233325e4a59fdcb12265043 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 30 May 2023 12:41:51 -0500 Subject: [PATCH] Remove outdated HAOS check from bluetooth (#93809) --- .../components/bluetooth/__init__.py | 61 ++----------------- .../components/bluetooth/manifest.json | 1 - .../components/bluetooth/strings.json | 6 -- tests/components/bluetooth/test_init.py | 27 +------- 4 files changed, 6 insertions(+), 89 deletions(-) diff --git a/homeassistant/components/bluetooth/__init__.py b/homeassistant/components/bluetooth/__init__.py index 3e35c97ca34b73..8d3bc0ae5e2fef 100644 --- a/homeassistant/components/bluetooth/__init__.py +++ b/homeassistant/components/bluetooth/__init__.py @@ -6,7 +6,6 @@ import platform from typing import TYPE_CHECKING -from awesomeversion import AwesomeVersion from bleak_retry_connector import BleakSlotManager from bluetooth_adapters import ( ADAPTER_ADDRESS, @@ -25,12 +24,8 @@ from home_assistant_bluetooth import BluetoothServiceInfo, BluetoothServiceInfoBleak from homeassistant.components import usb -from homeassistant.config_entries import ( - SOURCE_IGNORE, - SOURCE_INTEGRATION_DISCOVERY, - ConfigEntry, -) -from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP +from homeassistant.config_entries import SOURCE_INTEGRATION_DISCOVERY, ConfigEntry +from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.core import Event, HassJob, HomeAssistant, callback as hass_callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import ( @@ -40,11 +35,7 @@ ) from homeassistant.helpers.debounce import Debouncer from homeassistant.helpers.event import async_call_later -from homeassistant.helpers.issue_registry import ( - IssueSeverity, - async_create_issue, - async_delete_issue, -) +from homeassistant.helpers.issue_registry import async_delete_issue from homeassistant.loader import async_get_bluetooth from . import models @@ -121,8 +112,6 @@ _LOGGER = logging.getLogger(__name__) -RECOMMENDED_MIN_HAOS_VERSION = AwesomeVersion("9.0.dev0") - CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) @@ -133,43 +122,6 @@ async def _async_get_adapter_from_address( return await _get_manager(hass).async_get_adapter_from_address(address) -@hass_callback -def _async_haos_is_new_enough(hass: HomeAssistant) -> bool: - """Check if the version of Home Assistant Operating System is new enough.""" - # Only warn if a USB adapter is plugged in - if not any( - entry - for entry in hass.config_entries.async_entries(DOMAIN) - if entry.source != SOURCE_IGNORE - ): - return True - if ( - not hass.components.hassio.is_hassio() - or not (os_info := hass.components.hassio.get_os_info()) - or not (haos_version := os_info.get("version")) - or AwesomeVersion(haos_version) >= RECOMMENDED_MIN_HAOS_VERSION - ): - return True - return False - - -@hass_callback -def _async_check_haos(hass: HomeAssistant) -> None: - """Create or delete an the haos_outdated issue.""" - if _async_haos_is_new_enough(hass): - async_delete_issue(hass, DOMAIN, "haos_outdated") - return - async_create_issue( - hass, - DOMAIN, - "haos_outdated", - is_fixable=False, - severity=IssueSeverity.WARNING, - learn_more_url="/config/updates", - translation_key="haos_outdated", - ) - - async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the bluetooth integration.""" integration_matcher = IntegrationMatcher(await async_get_bluetooth(hass)) @@ -242,12 +194,7 @@ def _async_trigger_discovery() -> None: EVENT_HOMEASSISTANT_STOP, hass_callback(lambda event: cancel()) ) - # Wait to check until after start to make sure - # that the system info is available. - hass.bus.async_listen_once( - EVENT_HOMEASSISTANT_STARTED, - hass_callback(lambda event: _async_check_haos(hass)), - ) + async_delete_issue(hass, DOMAIN, "haos_outdated") return True diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index e7f95a2b63a3ef..8d936b7286ffb4 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -1,7 +1,6 @@ { "domain": "bluetooth", "name": "Bluetooth", - "after_dependencies": ["hassio"], "codeowners": ["@bdraco"], "config_flow": true, "dependencies": ["logger", "usb"], diff --git a/homeassistant/components/bluetooth/strings.json b/homeassistant/components/bluetooth/strings.json index a988477778d97e..cae88ef24c19c8 100644 --- a/homeassistant/components/bluetooth/strings.json +++ b/homeassistant/components/bluetooth/strings.json @@ -1,10 +1,4 @@ { - "issues": { - "haos_outdated": { - "title": "Update to Home Assistant Operating System 9.0 or later", - "description": "To improve Bluetooth reliability and performance, we highly recommend you update to version 9.0 or later of the Home Assistant Operating System." - } - }, "config": { "flow_title": "{name}", "step": { diff --git a/tests/components/bluetooth/test_init.py b/tests/components/bluetooth/test_init.py index d9901a68b0fdb5..24f1039175b8c0 100644 --- a/tests/components/bluetooth/test_init.py +++ b/tests/components/bluetooth/test_init.py @@ -8,7 +8,6 @@ from bleak.backends.scanner import AdvertisementData, BLEDevice from bluetooth_adapters import DEFAULT_ADDRESS import pytest -from syrupy.assertion import SnapshotAssertion from homeassistant.components import bluetooth from homeassistant.components.bluetooth import ( @@ -2922,35 +2921,13 @@ def _async_register_scan_request_callback(_hass, _callback): assert len(hass.config_entries.flow.async_progress(DOMAIN)) == 1 -async def test_issue_outdated_haos( - hass: HomeAssistant, - mock_bleak_scanner_start: MagicMock, - one_adapter: None, - operating_system_85: None, - snapshot: SnapshotAssertion, -) -> None: - """Test we create an issue on outdated haos.""" - entry = MockConfigEntry( - domain=bluetooth.DOMAIN, data={}, unique_id="00:00:00:00:00:01" - ) - entry.add_to_hass(hass) - assert await async_setup_component(hass, bluetooth.DOMAIN, {}) - await hass.async_block_till_done() - hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) - await hass.async_block_till_done() - registry = async_get_issue_registry(hass) - issue = registry.async_get_issue(DOMAIN, "haos_outdated") - assert issue is not None - assert issue == snapshot - - -async def test_issue_outdated_haos_no_adapters( +async def test_issue_outdated_haos_removed( hass: HomeAssistant, mock_bleak_scanner_start: MagicMock, no_adapters: None, operating_system_85: None, ) -> None: - """Test we do not create an issue on outdated haos if there are no adapters.""" + """Test we do not create an issue on outdated haos anymore.""" assert await async_setup_component(hass, bluetooth.DOMAIN, {}) await hass.async_block_till_done() hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)