mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 21:25:13 +02:00
deprecation for yaml import
This commit is contained in:
@@ -7,7 +7,14 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_NAME, CONF_API_KEY, CONF_NAME, CONF_URL, Platform
|
||||
from homeassistant.const import (
|
||||
ATTR_NAME,
|
||||
CONF_API_KEY,
|
||||
CONF_NAME,
|
||||
CONF_SENSORS,
|
||||
CONF_URL,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
@@ -26,13 +33,19 @@ from .const import (
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SENSORS_TYPES = ["name", "hp", "maxHealth", "mp", "maxMP", "exp", "toNextLevel", "lvl"]
|
||||
|
||||
INSTANCE_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_SENSORS),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_URL, default=DEFAULT_URL): cv.url,
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
vol.Required(CONF_API_USER): cv.string,
|
||||
vol.Required(CONF_API_KEY): cv.string,
|
||||
vol.Optional(CONF_SENSORS, default=list(SENSORS_TYPES)): vol.All(
|
||||
cv.ensure_list, vol.Unique(), [vol.In(list(SENSORS_TYPES))]
|
||||
),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
@@ -10,9 +10,10 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import CONF_API_KEY, CONF_NAME, CONF_URL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
|
||||
from .const import CONF_API_USER, DEFAULT_URL, DOMAIN
|
||||
|
||||
@@ -79,6 +80,19 @@ class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
"""Import habitica config from configuration.yaml."""
|
||||
async_create_issue(
|
||||
self.hass,
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_yaml_{DOMAIN}",
|
||||
is_fixable=False,
|
||||
breaks_in_ha_version="2024.12.0",
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_yaml",
|
||||
translation_placeholders={
|
||||
"domain": DOMAIN,
|
||||
"integration_title": "Habitica",
|
||||
},
|
||||
)
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user