Compare commits

...

4 Commits

Author SHA1 Message Date
epenet
08a94d50c0 Improve 2026-03-17 15:39:27 +00:00
epenet
c726f9d58c Simplify 2026-03-17 15:25:31 +00:00
epenet
298be17558 Tests 2026-03-17 15:23:55 +00:00
epenet
48542b7789 Raise issue on vera deprecated YAML 2026-03-17 15:14:32 +00:00
4 changed files with 60 additions and 11 deletions

View File

@@ -18,9 +18,10 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import config_validation as cv, issue_registry as ir
from homeassistant.helpers.typing import ConfigType
from .common import (
@@ -61,17 +62,53 @@ async def async_setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
if not (config := base_config.get(DOMAIN)):
return True
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data=config,
)
)
hass.async_create_task(_async_setup(hass, config))
return True
async def _async_setup(hass: HomeAssistant, config: ConfigType) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data=config,
)
if (
result.get("type") is FlowResultType.ABORT
and result.get("reason") != "already_configured"
):
ir.async_create_issue(
hass,
DOMAIN,
f"deprecated_yaml_import_issue_{result.get('reason')}",
breaks_in_ha_version="2026.10.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=ir.IssueSeverity.WARNING,
translation_key=f"deprecated_yaml_import_issue_{result.get('reason')}",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "Vera",
},
)
return
ir.async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"deprecated_yaml_{DOMAIN}",
breaks_in_ha_version="2026.10.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=ir.IssueSeverity.WARNING,
translation_key="deprecated_yaml",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "Vera",
},
)
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Do setup of vera."""
# Use options entered during initial config flow or provided from configuration.yml

View File

@@ -17,6 +17,12 @@
}
}
},
"issues": {
"deprecated_yaml_import_issue_cannot_connect": {
"description": "Configuring {integration_title} via YAML is deprecated and will be removed in a future release. While importing your configuration, a connection error occurred. Please correct your YAML configuration and restart Home Assistant, or remove the {domain} key from your configuration and configure the integration via the UI.",
"title": "The {integration_title} YAML configuration is being removed"
}
},
"options": {
"step": {
"init": {

View File

@@ -129,7 +129,7 @@ async def test_async_step_finish_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
context={"source": config_entries.SOURCE_USER},
data={CONF_CONTROLLER: "http://127.0.0.1:123/"},
)

View File

@@ -14,7 +14,7 @@ from homeassistant.components.vera import (
)
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers import entity_registry as er, issue_registry as ir
from .common import ComponentFactory, ConfigSource, new_simple_controller_config
@@ -53,6 +53,7 @@ async def test_init_from_file(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
vera_component_factory: ComponentFactory,
issue_registry: ir.IssueRegistry,
) -> None:
"""Test function."""
vera_device1: pv.VeraBinarySensor = MagicMock(spec=pv.VeraBinarySensor)
@@ -76,6 +77,11 @@ async def test_init_from_file(
assert entry1
assert entry1.unique_id == "vera_first_serial_1"
# Check that a deprecation repair issue was created
issue = issue_registry.async_get_issue("homeassistant", f"deprecated_yaml_{DOMAIN}")
assert issue is not None
assert issue.severity == "warning"
async def test_multiple_controllers_with_legacy_one(
hass: HomeAssistant,