Remove configuration.yaml support for the velbus component (#60411)
This commit is contained in:
parent
c407e24a18
commit
f18fe342ac
3 changed files with 4 additions and 58 deletions
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue