From f18fe342ace7fe4fb687b17edfb8a4e116a2d286 Mon Sep 17 00:00:00 2001 From: Maikel Punie Date: Mon, 29 Nov 2021 16:33:26 +0100 Subject: [PATCH] Remove configuration.yaml support for the velbus component (#60411) --- homeassistant/components/velbus/__init__.py | 30 ++----------------- .../components/velbus/config_flow.py | 10 ------- tests/components/velbus/test_config_flow.py | 22 ++------------ 3 files changed, 4 insertions(+), 58 deletions(-) diff --git a/homeassistant/components/velbus/__init__.py b/homeassistant/components/velbus/__init__.py index a63a533e487..330a4315a25 100644 --- a/homeassistant/components/velbus/__init__.py +++ b/homeassistant/components/velbus/__init__.py @@ -7,14 +7,13 @@ from velbusaio.channels import Channel as VelbusChannel from velbusaio.controller import Velbus import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_PORT +from homeassistant.config_entries import ConfigEntry +from homeassistant.const import CONF_ADDRESS, CONF_PORT from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import device_registry import homeassistant.helpers.config_validation as cv from homeassistant.helpers.device_registry import DeviceEntry from homeassistant.helpers.entity import DeviceInfo, Entity -from homeassistant.helpers.typing import ConfigType from .const import ( CONF_INTERFACE, @@ -27,34 +26,9 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -CONFIG_SCHEMA = vol.Schema( - {DOMAIN: vol.Schema({vol.Required(CONF_PORT): cv.string})}, extra=vol.ALLOW_EXTRA -) - PLATFORMS = ["switch", "sensor", "binary_sensor", "cover", "climate", "light"] -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the Velbus platform.""" - # Import from the configuration file if needed - if DOMAIN not in config: - return True - - _LOGGER.warning("Loading VELBUS via configuration.yaml is deprecated") - - port = config[DOMAIN].get(CONF_PORT) - data = {} - - if port: - data = {CONF_PORT: port, CONF_NAME: "Velbus import"} - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=data - ) - ) - return True - - async def velbus_connect_task( controller: Velbus, hass: HomeAssistant, entry_id: str ) -> None: diff --git a/homeassistant/components/velbus/config_flow.py b/homeassistant/components/velbus/config_flow.py index 3facd8c6a33..3a057b482df 100644 --- a/homeassistant/components/velbus/config_flow.py +++ b/homeassistant/components/velbus/config_flow.py @@ -82,13 +82,3 @@ class VelbusConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ), errors=self._errors, ) - - async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult: - """Import a config entry.""" - user_input[CONF_NAME] = "Velbus Import" - prt = user_input[CONF_PORT] - if self._prt_in_configuration_exists(prt): - # if the velbus import is already in the config - # we should not proceed the import - return self.async_abort(reason="already_configured") - return await self.async_step_user(user_input) diff --git a/tests/components/velbus/test_config_flow.py b/tests/components/velbus/test_config_flow.py index 6c10b3c84f4..01a40af1751 100644 --- a/tests/components/velbus/test_config_flow.py +++ b/tests/components/velbus/test_config_flow.py @@ -77,29 +77,11 @@ async def test_user_fail(hass: HomeAssistant): assert result["errors"] == {CONF_PORT: "cannot_connect"} -@pytest.mark.usefixtures("controller") -async def test_import(hass: HomeAssistant): - """Test import step.""" - flow = init_config_flow(hass) - - result = await flow.async_step_import({CONF_PORT: PORT_TCP}) - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result["title"] == "velbus_import" - - @pytest.mark.usefixtures("config_entry") async def test_abort_if_already_setup(hass: HomeAssistant): - """Test we abort if Daikin is already setup.""" + """Test we abort if Velbus is already setup.""" flow = init_config_flow(hass) - result = await flow.async_step_import( - {CONF_PORT: PORT_TCP, CONF_NAME: "velbus import test"} - ) - assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "already_configured" - - result = await flow.async_step_user( - {CONF_PORT: PORT_TCP, CONF_NAME: "velbus import test"} - ) + result = await flow.async_step_user({CONF_PORT: PORT_TCP, CONF_NAME: "velbus test"}) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["errors"] == {"port": "already_configured"}