Remove yaml support from Synology DSM (#53197)
parent
d4589894fe
commit
1b478ba02e
|
@ -21,12 +21,10 @@ from synology_dsm.exceptions import (
|
|||
SynologyDSMLoginFailedException,
|
||||
SynologyDSMRequestException,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
CONF_DISKS,
|
||||
CONF_HOST,
|
||||
CONF_MAC,
|
||||
CONF_PASSWORD,
|
||||
|
@ -46,7 +44,6 @@ from homeassistant.helpers.device_registry import (
|
|||
async_get_registry as get_dev_reg,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -56,12 +53,10 @@ from homeassistant.helpers.update_coordinator import (
|
|||
from .const import (
|
||||
CONF_DEVICE_TOKEN,
|
||||
CONF_SERIAL,
|
||||
CONF_VOLUMES,
|
||||
COORDINATOR_CAMERAS,
|
||||
COORDINATOR_CENTRAL,
|
||||
COORDINATOR_SWITCHES,
|
||||
DEFAULT_SCAN_INTERVAL,
|
||||
DEFAULT_USE_SSL,
|
||||
DEFAULT_VERIFY_SSL,
|
||||
DOMAIN,
|
||||
ENTITY_CLASS,
|
||||
|
@ -83,26 +78,8 @@ from .const import (
|
|||
EntityInfo,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT): cv.port,
|
||||
vol.Optional(CONF_SSL, default=DEFAULT_USE_SSL): cv.boolean,
|
||||
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_DISKS): cv.ensure_list,
|
||||
vol.Optional(CONF_VOLUMES): cv.ensure_list,
|
||||
}
|
||||
)
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
cv.deprecated(DOMAIN),
|
||||
{DOMAIN: vol.Schema(vol.All(cv.ensure_list, [CONFIG_SCHEMA]))},
|
||||
),
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
ATTRIBUTION = "Data provided by Synology"
|
||||
|
||||
|
@ -110,25 +87,6 @@ ATTRIBUTION = "Data provided by Synology"
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up Synology DSM sensors from legacy config file."""
|
||||
|
||||
conf = config.get(DOMAIN)
|
||||
if conf is None:
|
||||
return True
|
||||
|
||||
for dsm_conf in conf:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=dsm_conf,
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry( # noqa: C901
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> bool:
|
||||
|
|
|
@ -227,12 +227,6 @@ class SynologyDSMFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
self.context["title_placeholders"] = self.discovered_conf
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_step_import(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Import a config entry."""
|
||||
return await self.async_step_user(user_input)
|
||||
|
||||
async def async_step_link(self, user_input: dict[str, Any]) -> FlowResult:
|
||||
"""Link a config entry from discovery."""
|
||||
return await self.async_step_user(user_input)
|
||||
|
|
|
@ -23,7 +23,7 @@ from homeassistant.components.synology_dsm.const import (
|
|||
DEFAULT_VERIFY_SSL,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
CONF_DISKS,
|
||||
CONF_HOST,
|
||||
|
@ -41,7 +41,6 @@ from homeassistant.core import HomeAssistant
|
|||
from .consts import (
|
||||
DEVICE_TOKEN,
|
||||
HOST,
|
||||
HOST_2,
|
||||
MACS,
|
||||
PASSWORD,
|
||||
PORT,
|
||||
|
@ -256,59 +255,6 @@ async def test_user_vdsm(hass: HomeAssistant, service_vdsm: MagicMock):
|
|||
assert result["data"].get(CONF_VOLUMES) is None
|
||||
|
||||
|
||||
async def test_import(hass: HomeAssistant, service: MagicMock):
|
||||
"""Test import step."""
|
||||
# import with minimum setup
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={CONF_HOST: HOST, CONF_USERNAME: USERNAME, CONF_PASSWORD: PASSWORD},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["result"].unique_id == SERIAL
|
||||
assert result["title"] == HOST
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
assert result["data"][CONF_PORT] == DEFAULT_PORT_SSL
|
||||
assert result["data"][CONF_SSL] == DEFAULT_USE_SSL
|
||||
assert result["data"][CONF_VERIFY_SSL] == DEFAULT_VERIFY_SSL
|
||||
assert result["data"][CONF_USERNAME] == USERNAME
|
||||
assert result["data"][CONF_PASSWORD] == PASSWORD
|
||||
assert result["data"][CONF_MAC] == MACS
|
||||
assert result["data"].get("device_token") is None
|
||||
assert result["data"].get(CONF_DISKS) is None
|
||||
assert result["data"].get(CONF_VOLUMES) is None
|
||||
|
||||
service.return_value.information.serial = SERIAL_2
|
||||
# import with all
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={
|
||||
CONF_HOST: HOST_2,
|
||||
CONF_PORT: PORT,
|
||||
CONF_SSL: USE_SSL,
|
||||
CONF_VERIFY_SSL: VERIFY_SSL,
|
||||
CONF_USERNAME: USERNAME,
|
||||
CONF_PASSWORD: PASSWORD,
|
||||
CONF_DISKS: ["sda", "sdb", "sdc"],
|
||||
CONF_VOLUMES: ["volume_1"],
|
||||
},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["result"].unique_id == SERIAL_2
|
||||
assert result["title"] == HOST_2
|
||||
assert result["data"][CONF_HOST] == HOST_2
|
||||
assert result["data"][CONF_PORT] == PORT
|
||||
assert result["data"][CONF_SSL] == USE_SSL
|
||||
assert result["data"][CONF_VERIFY_SSL] == VERIFY_SSL
|
||||
assert result["data"][CONF_USERNAME] == USERNAME
|
||||
assert result["data"][CONF_PASSWORD] == PASSWORD
|
||||
assert result["data"][CONF_MAC] == MACS
|
||||
assert result["data"].get("device_token") is None
|
||||
assert result["data"][CONF_DISKS] == ["sda", "sdb", "sdc"]
|
||||
assert result["data"][CONF_VOLUMES] == ["volume_1"]
|
||||
|
||||
|
||||
async def test_abort_if_already_setup(hass: HomeAssistant, service: MagicMock):
|
||||
"""Test we abort if the account is already setup."""
|
||||
MockConfigEntry(
|
||||
|
@ -317,15 +263,6 @@ async def test_abort_if_already_setup(hass: HomeAssistant, service: MagicMock):
|
|||
unique_id=SERIAL,
|
||||
).add_to_hass(hass)
|
||||
|
||||
# Should fail, same HOST:PORT (import)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={CONF_HOST: HOST, CONF_USERNAME: USERNAME, CONF_PASSWORD: PASSWORD},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
# Should fail, same HOST:PORT (flow)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
|
Loading…
Reference in New Issue