mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Remove deprecated YAML for freebox (#107497)
This commit is contained in:
parent
442eb68d92
commit
40e1bab0ac
@ -3,70 +3,21 @@ from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from freebox_api.exceptions import HttpRequestError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import (
|
||||
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||
Event,
|
||||
HomeAssistant,
|
||||
ServiceCall,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant, ServiceCall
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, PLATFORMS, SERVICE_REBOOT
|
||||
from .router import FreeboxRouter, get_api
|
||||
|
||||
FREEBOX_SCHEMA = vol.Schema(
|
||||
{vol.Required(CONF_HOST): cv.string, vol.Required(CONF_PORT): cv.port}
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
cv.deprecated(DOMAIN),
|
||||
{DOMAIN: vol.Schema(vol.All(cv.ensure_list, [FREEBOX_SCHEMA]))},
|
||||
),
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Set up the Freebox integration."""
|
||||
if DOMAIN in config:
|
||||
for entry_config in config[DOMAIN]:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=entry_config
|
||||
)
|
||||
)
|
||||
|
||||
async_create_issue(
|
||||
hass,
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_yaml_{DOMAIN}",
|
||||
breaks_in_ha_version="2024.2.0",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_yaml",
|
||||
translation_placeholders={
|
||||
"domain": DOMAIN,
|
||||
"integration_title": "Freebox",
|
||||
},
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Freebox entry."""
|
||||
api = await get_api(hass, entry.data[CONF_HOST])
|
||||
|
@ -98,12 +98,6 @@ class FreeboxFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return self.async_show_form(step_id="link", errors=errors)
|
||||
|
||||
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_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
|
@ -11,7 +11,7 @@ from freebox_api.exceptions import (
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.freebox.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
@ -58,17 +58,6 @@ async def test_user(hass: HomeAssistant) -> None:
|
||||
assert result["step_id"] == "link"
|
||||
|
||||
|
||||
async def test_import(hass: HomeAssistant) -> None:
|
||||
"""Test import step."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
|
||||
|
||||
async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
"""Test zeroconf step."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -83,8 +72,6 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
async def test_link(hass: HomeAssistant, router: Mock) -> None:
|
||||
"""Test linking."""
|
||||
with patch(
|
||||
"homeassistant.components.freebox.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"homeassistant.components.freebox.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
@ -101,7 +88,6 @@ async def test_link(hass: HomeAssistant, router: Mock) -> None:
|
||||
assert result["data"][CONF_HOST] == MOCK_HOST
|
||||
assert result["data"][CONF_PORT] == MOCK_PORT
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@ -113,15 +99,6 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||
unique_id=MOCK_HOST,
|
||||
).add_to_hass(hass)
|
||||
|
||||
# Should fail, same MOCK_HOST (import)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
# Should fail, same MOCK_HOST (flow)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
Loading…
x
Reference in New Issue
Block a user