From 24ce3d7daa3dcfcc679f282fb2713765caaf93e5 Mon Sep 17 00:00:00 2001 From: Noah Husby <32528627+noahhusby@users.noreply.github.com> Date: Fri, 27 Dec 2024 15:27:33 -0500 Subject: [PATCH] Remove deprecated yaml import for Russound RIO (#134072) --- .../components/russound_rio/config_flow.py | 23 -------- .../components/russound_rio/media_player.py | 56 +------------------ .../russound_rio/quality_scale.yaml | 5 +- .../russound_rio/test_config_flow.py | 33 +---------- 4 files changed, 7 insertions(+), 110 deletions(-) diff --git a/homeassistant/components/russound_rio/config_flow.py b/homeassistant/components/russound_rio/config_flow.py index f7f2e5b1d00..80da8c903d3 100644 --- a/homeassistant/components/russound_rio/config_flow.py +++ b/homeassistant/components/russound_rio/config_flow.py @@ -78,26 +78,3 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): data_schema=DATA_SCHEMA, ) return await self.async_step_user(user_input) - - async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Attempt to import the existing configuration.""" - self._async_abort_entries_match({CONF_HOST: import_data[CONF_HOST]}) - host = import_data[CONF_HOST] - port = import_data.get(CONF_PORT, 9621) - - # Connection logic is repeated here since this method will be removed in future releases - client = RussoundClient(RussoundTcpConnectionHandler(host, port)) - try: - await client.connect() - controller = client.controllers[1] - await client.disconnect() - except RUSSOUND_RIO_EXCEPTIONS: - _LOGGER.exception("Could not connect to Russound RIO") - return self.async_abort( - reason="cannot_connect", description_placeholders={} - ) - else: - await self.async_set_unique_id(controller.mac_address) - self._abort_if_unique_id_configured() - data = {CONF_HOST: host, CONF_PORT: port} - return self.async_create_entry(title=controller.controller_type, data=data) diff --git a/homeassistant/components/russound_rio/media_player.py b/homeassistant/components/russound_rio/media_player.py index 02467731ec3..b7ad4f5d89b 100644 --- a/homeassistant/components/russound_rio/media_player.py +++ b/homeassistant/components/russound_rio/media_player.py @@ -18,15 +18,11 @@ from homeassistant.components.media_player import ( MediaPlayerState, MediaType, ) -from homeassistant.config_entries import SOURCE_IMPORT -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -from homeassistant.data_entry_flow import FlowResultType +from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import RussoundConfigEntry -from .const import DOMAIN, MP_FEATURES_BY_FLAG +from .const import MP_FEATURES_BY_FLAG from .entity import RussoundBaseEntity, command _LOGGER = logging.getLogger(__name__) @@ -34,54 +30,6 @@ _LOGGER = logging.getLogger(__name__) PARALLEL_UPDATES = 0 -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - async_add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the Russound RIO platform.""" - - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=config, - ) - if ( - result["type"] is FlowResultType.CREATE_ENTRY - or result["reason"] == "single_instance_allowed" - ): - async_create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_yaml_{DOMAIN}", - breaks_in_ha_version="2025.2.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "Russound RIO", - }, - ) - return - async_create_issue( - hass, - DOMAIN, - f"deprecated_yaml_import_issue_{result['reason']}", - breaks_in_ha_version="2025.2.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key=f"deprecated_yaml_import_issue_{result['reason']}", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "Russound RIO", - }, - ) - - async def async_setup_entry( hass: HomeAssistant, entry: RussoundConfigEntry, diff --git a/homeassistant/components/russound_rio/quality_scale.yaml b/homeassistant/components/russound_rio/quality_scale.yaml index bd511802467..d2bf8065c1b 100644 --- a/homeassistant/components/russound_rio/quality_scale.yaml +++ b/homeassistant/components/russound_rio/quality_scale.yaml @@ -68,7 +68,10 @@ rules: reconfiguration-flow: done dynamic-devices: todo discovery-update-info: todo - repair-issues: done + repair-issues: + status: exempt + comment: | + This integration doesn't have any cases where raising an issue is needed. docs-use-cases: done docs-supported-devices: done docs-supported-functions: todo diff --git a/tests/components/russound_rio/test_config_flow.py b/tests/components/russound_rio/test_config_flow.py index 7a3b7fac7da..060d5114f59 100644 --- a/tests/components/russound_rio/test_config_flow.py +++ b/tests/components/russound_rio/test_config_flow.py @@ -3,7 +3,7 @@ from unittest.mock import AsyncMock from homeassistant.components.russound_rio.const import DOMAIN -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER, ConfigFlowResult +from homeassistant.config_entries import SOURCE_USER, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -89,37 +89,6 @@ async def test_duplicate( assert result["reason"] == "already_configured" -async def test_import( - hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_russound_client: AsyncMock -) -> None: - """Test we import a config entry.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=MOCK_CONFIG, - ) - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == MODEL - assert result["data"] == MOCK_CONFIG - assert len(mock_setup_entry.mock_calls) == 1 - assert result["result"].unique_id == "00:11:22:33:44:55" - - -async def test_import_cannot_connect( - hass: HomeAssistant, mock_russound_client: AsyncMock -) -> None: - """Test we handle import cannot connect error.""" - mock_russound_client.connect.side_effect = TimeoutError - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_CONFIG - ) - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "cannot_connect" - - async def _start_reconfigure_flow( hass: HomeAssistant, mock_config_entry: MockConfigEntry ) -> ConfigFlowResult: