Deprecate YAML config for ReCollect Waste (#55426)
This commit is contained in:
parent
b43c80ca21
commit
32df2f7d8b
3 changed files with 5 additions and 56 deletions
|
@ -33,12 +33,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""Define the config flow to handle options."""
|
||||
return RecollectWasteOptionsFlowHandler(config_entry)
|
||||
|
||||
async def async_step_import(
|
||||
self, import_config: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle configuration via YAML import."""
|
||||
return await self.async_step_user(import_config)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
|
|
|
@ -2,26 +2,23 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from aiorecollect.client import PickupType
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
CONF_FRIENDLY_NAME,
|
||||
CONF_NAME,
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DATA_COORDINATOR, DOMAIN, LOGGER
|
||||
from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DATA_COORDINATOR, DOMAIN
|
||||
|
||||
ATTR_PICKUP_TYPES = "pickup_types"
|
||||
ATTR_AREA_NAME = "area_name"
|
||||
|
@ -31,13 +28,7 @@ ATTR_NEXT_PICKUP_DATE = "next_pickup_date"
|
|||
DEFAULT_ATTRIBUTION = "Pickup data provided by ReCollect Waste"
|
||||
DEFAULT_NAME = "Waste Pickup"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_PLACE_ID): cv.string,
|
||||
vol.Required(CONF_SERVICE_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
}
|
||||
)
|
||||
PLATFORM_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -53,26 +44,6 @@ def async_get_pickup_type_names(
|
|||
]
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Import Recollect Waste configuration from YAML."""
|
||||
LOGGER.warning(
|
||||
"Loading ReCollect Waste via platform setup is deprecated; "
|
||||
"Please remove it from your configuration"
|
||||
)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=config,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
|
|
|
@ -9,7 +9,7 @@ from homeassistant.components.recollect_waste import (
|
|||
CONF_SERVICE_ID,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_FRIENDLY_NAME
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -81,22 +81,6 @@ async def test_show_form(hass):
|
|||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
async def test_step_import(hass):
|
||||
"""Test that the user step works."""
|
||||
conf = {CONF_PLACE_ID: "12345", CONF_SERVICE_ID: "12345"}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.recollect_waste.async_setup_entry", return_value=True
|
||||
), patch("aiorecollect.client.Client.async_get_pickup_events", return_value=True):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == "12345, 12345"
|
||||
assert result["data"] == {CONF_PLACE_ID: "12345", CONF_SERVICE_ID: "12345"}
|
||||
|
||||
|
||||
async def test_step_user(hass):
|
||||
"""Test that the user step works."""
|
||||
conf = {CONF_PLACE_ID: "12345", CONF_SERVICE_ID: "12345"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue