Remove yaml import anthemav (#79931)

This commit is contained in:
G Johansson 2022-10-26 12:42:21 +02:00 committed by GitHub
parent e3233f72ce
commit 9715b6c862
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 98 deletions

View file

@ -92,9 +92,3 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)
async def async_step_import(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Import a config entry from configuration.yaml."""
return await self.async_step_user(user_input)

View file

@ -5,73 +5,24 @@ import logging
from anthemav.connection import Connection
from anthemav.protocol import AVR
import voluptuous as vol
from homeassistant.components.media_player import (
PLATFORM_SCHEMA,
MediaPlayerDeviceClass,
MediaPlayerEntity,
MediaPlayerEntityFeature,
MediaPlayerState,
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_MAC, CONF_NAME
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo
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 .const import (
ANTHEMAV_UDATE_SIGNAL,
CONF_MODEL,
DEFAULT_NAME,
DEFAULT_PORT,
DOMAIN,
MANUFACTURER,
)
from .const import ANTHEMAV_UDATE_SIGNAL, CONF_MODEL, DOMAIN, MANUFACTURER
_LOGGER = logging.getLogger(__name__)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
}
)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up our socket to the AVR."""
async_create_issue(
hass,
DOMAIN,
"deprecated_yaml",
breaks_in_ha_version="2022.10.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
)
_LOGGER.warning(
"Configuration of the Anthem A/V Receivers integration in YAML is "
"deprecated and will be removed in Home Assistant 2022.10; Your "
"existing configuration has been imported into the UI automatically "
"and can be safely removed from your configuration.yaml file"
)
await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data=config,
)
async def async_setup_entry(
hass: HomeAssistant,

View file

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

View file

@ -15,11 +15,5 @@
}
}
}
},
"issues": {
"deprecated_yaml": {
"description": "Configuring Anthem A/V Receivers using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the Anthem A/V Receivers YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.",
"title": "The Anthem A/V Receivers YAML configuration is being removed"
}
}
}

View file

@ -2,10 +2,9 @@
from unittest.mock import AsyncMock, patch
from anthemav.device_error import DeviceError
import pytest
from homeassistant.components.anthemav.const import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@ -95,36 +94,11 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
assert result2["errors"] == {"base": "cannot_connect"}
async def test_import_configuration(
hass: HomeAssistant, mock_connection_create: AsyncMock, mock_anthemav: AsyncMock
) -> None:
"""Test we import existing configuration."""
config = {
"host": "1.1.1.1",
"port": 14999,
"name": "Anthem Av Import",
}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["data"] == {
"host": "1.1.1.1",
"port": 14999,
"name": "Anthem Av Import",
"mac": "00:00:00:00:00:01",
"model": "MRX 520",
}
@pytest.mark.parametrize("source", [SOURCE_USER, SOURCE_IMPORT])
async def test_device_already_configured(
hass: HomeAssistant,
mock_connection_create: AsyncMock,
mock_anthemav: AsyncMock,
mock_config_entry: MockConfigEntry,
source: str,
) -> None:
"""Test we import existing configuration."""
config = {
@ -134,7 +108,7 @@ async def test_device_already_configured(
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": source}, data=config
DOMAIN, context={"source": SOURCE_USER}, data=config
)
assert result.get("type") == FlowResultType.ABORT