Remove deprecated yaml import in media extractor (#131426)
parent
c9ede11b1f
commit
ca3be6661a
|
@ -16,10 +16,9 @@ from homeassistant.components.media_player import (
|
|||
MEDIA_PLAYER_PLAY_MEDIA_SCHEMA,
|
||||
SERVICE_PLAY_MEDIA,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import (
|
||||
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||
HomeAssistant,
|
||||
ServiceCall,
|
||||
ServiceResponse,
|
||||
|
@ -27,7 +26,6 @@ from homeassistant.core import (
|
|||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
|
@ -43,19 +41,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
CONF_CUSTOMIZE_ENTITIES = "customize"
|
||||
CONF_DEFAULT_STREAM_QUERY = "default_query"
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_DEFAULT_STREAM_QUERY): cv.string,
|
||||
vol.Optional(CONF_CUSTOMIZE_ENTITIES): vol.Schema(
|
||||
{cv.entity_id: vol.Schema({cv.string: cv.string})}
|
||||
),
|
||||
}
|
||||
)
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
@ -67,29 +53,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the media extractor service."""
|
||||
|
||||
if DOMAIN in config:
|
||||
async_create_issue(
|
||||
hass,
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_yaml_{DOMAIN}",
|
||||
breaks_in_ha_version="2024.12.0",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_yaml",
|
||||
translation_placeholders={
|
||||
"domain": DOMAIN,
|
||||
"integration_title": "Media extractor",
|
||||
},
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
)
|
||||
)
|
||||
|
||||
async def extract_media_url(call: ServiceCall) -> ServiceResponse:
|
||||
"""Extract media url."""
|
||||
|
||||
|
|
|
@ -24,7 +24,3 @@ class MediaExtractorConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
return self.async_create_entry(title="Media extractor", data={})
|
||||
|
||||
return self.async_show_form(step_id="user", data_schema=vol.Schema({}))
|
||||
|
||||
async def async_step_import(self, import_data: None) -> ConfigFlowResult:
|
||||
"""Handle import."""
|
||||
return self.async_create_entry(title="Media extractor", data={})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for the Media extractor config flow."""
|
||||
|
||||
from homeassistant.components.media_extractor.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
|
||||
|
||||
|
@ -41,16 +41,3 @@ async def test_single_instance_allowed(hass: HomeAssistant) -> None:
|
|||
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "single_instance_allowed"
|
||||
|
||||
|
||||
async def test_import_flow(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||
"""Test import flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}
|
||||
)
|
||||
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "Media extractor"
|
||||
assert result.get("data") == {}
|
||||
assert result.get("options") == {}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
|
|
@ -22,12 +22,15 @@ from homeassistant.setup import async_setup_component
|
|||
from . import YOUTUBE_EMPTY_PLAYLIST, YOUTUBE_PLAYLIST, YOUTUBE_VIDEO, MockYoutubeDL
|
||||
from .const import NO_FORMATS_RESPONSE, SOUNDCLOUD_TRACK
|
||||
|
||||
from tests.common import load_json_object_fixture
|
||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||
|
||||
|
||||
async def test_play_media_service_is_registered(hass: HomeAssistant) -> None:
|
||||
"""Test play media service is registered."""
|
||||
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||
mock_config_entry = MockConfigEntry(domain=DOMAIN)
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.services.has_service(DOMAIN, SERVICE_PLAY_MEDIA)
|
||||
|
|
Loading…
Reference in New Issue