Remove qbittorrent YAML configuration (#93548)

Remove platform yaml qbittorrent
This commit is contained in:
G Johansson 2023-06-05 18:14:07 +02:00 committed by GitHub
parent 437de7c2a3
commit d9ac041e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 92 deletions

View File

@ -1,7 +1,6 @@
"""Config flow for qBittorrent."""
from __future__ import annotations
import logging
from typing import Any
from qbittorrent.client import LoginRequired
@ -9,20 +8,12 @@ from requests.exceptions import RequestException
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow
from homeassistant.const import (
CONF_NAME,
CONF_PASSWORD,
CONF_URL,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME, CONF_VERIFY_SSL
from homeassistant.data_entry_flow import FlowResult
from .const import DEFAULT_NAME, DEFAULT_URL, DOMAIN
from .helpers import setup_client
_LOGGER = logging.getLogger(__name__)
USER_DATA_SCHEMA = vol.Schema(
{
vol.Required(CONF_URL, default=DEFAULT_URL): str,
@ -61,16 +52,3 @@ class QbittorrentConfigFlow(ConfigFlow, domain=DOMAIN):
schema = self.add_suggested_values_to_schema(USER_DATA_SCHEMA, user_input)
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
"""Import a config entry from configuration.yaml."""
self._async_abort_entries_match({CONF_URL: config[CONF_URL]})
return self.async_create_entry(
title=config.get(CONF_NAME, DEFAULT_NAME),
data={
CONF_URL: config[CONF_URL],
CONF_USERNAME: config[CONF_USERNAME],
CONF_PASSWORD: config[CONF_PASSWORD],
CONF_VERIFY_SSL: True,
},
)

View File

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_NAME,
CONF_PASSWORD,
@ -24,10 +24,8 @@ from homeassistant.const import (
UnitOfDataRate,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import DEFAULT_NAME, DOMAIN
@ -70,29 +68,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the qBittorrent platform."""
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
)
)
ir.async_create_issue(
hass,
DOMAIN,
"deprecated_yaml",
breaks_in_ha_version="2023.6.0",
is_fixable=False,
severity=ir.IssueSeverity.WARNING,
translation_key="deprecated_yaml",
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,

View File

@ -17,11 +17,5 @@
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"issues": {
"deprecated_yaml": {
"title": "The qBittorrent YAML configuration is being removed",
"description": "Configuring qBittorrent using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the qBittorrent YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
}
}
}

View File

@ -4,7 +4,7 @@ from requests.exceptions import RequestException
import requests_mock
from homeassistant.components.qbittorrent.const import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import (
CONF_PASSWORD,
CONF_SOURCE,
@ -26,12 +26,6 @@ USER_INPUT = {
CONF_VERIFY_SSL: True,
}
YAML_IMPORT = {
CONF_URL: "http://localhost:8080",
CONF_USERNAME: "user",
CONF_PASSWORD: "pass",
}
async def test_flow_user(hass: HomeAssistant, mock_api: requests_mock.Mocker) -> None:
"""Test the user flow."""
@ -104,33 +98,3 @@ async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
)
assert result["type"] == FlowResultType.ABORT
assert result["reason"] == "already_configured"
async def test_flow_import(hass: HomeAssistant) -> None:
"""Test import step."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_IMPORT},
data=YAML_IMPORT,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_URL: "http://localhost:8080",
CONF_USERNAME: "user",
CONF_PASSWORD: "pass",
CONF_VERIFY_SSL: True,
}
async def test_flow_import_already_configured(hass: HomeAssistant) -> None:
"""Test import step already configured."""
entry = MockConfigEntry(domain=DOMAIN, data=USER_INPUT)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={CONF_SOURCE: SOURCE_IMPORT},
data=YAML_IMPORT,
)
assert result["type"] == FlowResultType.ABORT
assert result["reason"] == "already_configured"