Remove deprecated YAML configuration from Yamaha Music Cast (#69033)
parent
7a31c8f53c
commit
beb54dfb63
|
@ -131,18 +131,3 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
)
|
||||
|
||||
return self.async_show_form(step_id="confirm")
|
||||
|
||||
async def async_step_import(self, import_data: dict) -> data_entry_flow.FlowResult:
|
||||
"""Import data from configuration.yaml into the config flow."""
|
||||
res = await self.async_step_user(import_data)
|
||||
if res["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY:
|
||||
_LOGGER.info(
|
||||
"Successfully imported %s from configuration.yaml",
|
||||
import_data.get(CONF_HOST),
|
||||
)
|
||||
elif res["type"] == data_entry_flow.RESULT_TYPE_FORM:
|
||||
_LOGGER.error(
|
||||
"Could not import %s from configuration.yaml",
|
||||
import_data.get(CONF_HOST),
|
||||
)
|
||||
return res
|
||||
|
|
|
@ -34,7 +34,6 @@ HA_REPEAT_MODE_TO_MC_MAPPING = {
|
|||
|
||||
NULL_GROUP = "00000000000000000000000000000000"
|
||||
|
||||
INTERVAL_SECONDS = "interval_seconds"
|
||||
|
||||
MC_REPEAT_MODE_TO_HA_MAPPING = {
|
||||
val: key for key, val in HA_REPEAT_MODE_TO_MC_MAPPING.items()
|
||||
|
|
|
@ -6,14 +6,9 @@ import logging
|
|||
|
||||
from aiomusiccast import MusicCastGroupException, MusicCastMediaContent
|
||||
from aiomusiccast.features import ZoneFeature
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import media_source
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
BrowseMedia,
|
||||
MediaPlayerEntity,
|
||||
)
|
||||
from homeassistant.components.media_player import BrowseMedia, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.browse_media import (
|
||||
async_process_play_media_url,
|
||||
)
|
||||
|
@ -40,21 +35,12 @@ from homeassistant.components.media_player.const import (
|
|||
SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
STATE_IDLE,
|
||||
STATE_OFF,
|
||||
STATE_PAUSED,
|
||||
STATE_PLAYING,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import uuid
|
||||
|
||||
from . import MusicCastDataUpdateCoordinator, MusicCastDeviceEntity
|
||||
|
@ -64,7 +50,6 @@ from .const import (
|
|||
DEFAULT_ZONE,
|
||||
DOMAIN,
|
||||
HA_REPEAT_MODE_TO_MC_MAPPING,
|
||||
INTERVAL_SECONDS,
|
||||
MC_REPEAT_MODE_TO_HA_MAPPING,
|
||||
MEDIA_CLASS_MAPPING,
|
||||
NULL_GROUP,
|
||||
|
@ -81,42 +66,6 @@ MUSIC_PLAYER_BASE_SUPPORT = (
|
|||
| SUPPORT_PLAY_MEDIA
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=5000): cv.port,
|
||||
vol.Optional(INTERVAL_SECONDS, default=0): cv.positive_int,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_devices: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Import legacy configurations."""
|
||||
|
||||
if hass.config_entries.async_entries(DOMAIN) and config[CONF_HOST] not in [
|
||||
entry.data[CONF_HOST] for entry in hass.config_entries.async_entries(DOMAIN)
|
||||
]:
|
||||
_LOGGER.error(
|
||||
"Configuration in configuration.yaml is not supported anymore. "
|
||||
"Please add this device using the config flow: %s",
|
||||
config[CONF_HOST],
|
||||
)
|
||||
else:
|
||||
_LOGGER.warning(
|
||||
"Configuration in configuration.yaml is deprecated. Use the config flow instead"
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
|
|
@ -250,61 +250,6 @@ async def test_user_input_device_found_no_ssdp(
|
|||
}
|
||||
|
||||
|
||||
async def test_import_device_already_existing(
|
||||
hass, mock_get_device_info_valid, mock_get_source_ip
|
||||
):
|
||||
"""Test when the configurations.yaml contains an existing device."""
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="1234567890",
|
||||
data={CONF_HOST: "192.168.188.18", "model": "MC20", "serial": "1234567890"},
|
||||
)
|
||||
mock_entry.add_to_hass(hass)
|
||||
|
||||
config = {"platform": "yamaha_musiccast", "host": "192.168.188.18", "port": 5006}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_import_error(hass, mock_get_device_info_exception, mock_get_source_ip):
|
||||
"""Test when in the configuration.yaml a device is configured, which cannot be added.."""
|
||||
config = {"platform": "yamaha_musiccast", "host": "192.168.188.18", "port": 5006}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_import_device_successful(
|
||||
hass,
|
||||
mock_get_device_info_valid,
|
||||
mock_valid_discovery_information,
|
||||
mock_get_source_ip,
|
||||
):
|
||||
"""Test when the device was imported successfully."""
|
||||
config = {"platform": "yamaha_musiccast", "host": "127.0.0.1", "port": 5006}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert isinstance(result["result"], ConfigEntry)
|
||||
assert result["data"] == {
|
||||
"host": "127.0.0.1",
|
||||
"serial": "1234567890",
|
||||
"upnp_description": "http://127.0.0.1:9000/MediaRenderer/desc.xml",
|
||||
}
|
||||
|
||||
|
||||
# SSDP Flows
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue