mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Add repair hint to deprecate generic camera yaml config (#96923)
This commit is contained in:
parent
2365e4c159
commit
35f21dcf9c
@ -80,12 +80,6 @@ async def async_setup_platform(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a generic IP Camera."""
|
"""Set up a generic IP Camera."""
|
||||||
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Loading generic IP camera via configuration.yaml is deprecated, "
|
|
||||||
"it will be automatically imported. Once you have confirmed correct "
|
|
||||||
"operation, please remove 'generic' (IP camera) section(s) from "
|
|
||||||
"configuration.yaml"
|
|
||||||
)
|
|
||||||
image = config.get(CONF_STILL_IMAGE_URL)
|
image = config.get(CONF_STILL_IMAGE_URL)
|
||||||
stream = config.get(CONF_STREAM_SOURCE)
|
stream = config.get(CONF_STREAM_SOURCE)
|
||||||
config_new = {
|
config_new = {
|
||||||
|
@ -40,11 +40,12 @@ from homeassistant.const import (
|
|||||||
HTTP_BASIC_AUTHENTICATION,
|
HTTP_BASIC_AUTHENTICATION,
|
||||||
HTTP_DIGEST_AUTHENTICATION,
|
HTTP_DIGEST_AUTHENTICATION,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResult, UnknownFlow
|
from homeassistant.data_entry_flow import FlowResult, UnknownFlow
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
from homeassistant.helpers import config_validation as cv, template as template_helper
|
from homeassistant.helpers import config_validation as cv, template as template_helper
|
||||||
from homeassistant.helpers.httpx_client import get_async_client
|
from homeassistant.helpers.httpx_client import get_async_client
|
||||||
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from .camera import GenericCamera, generate_auth
|
from .camera import GenericCamera, generate_auth
|
||||||
@ -380,6 +381,28 @@ class GenericIPCamConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult:
|
||||||
"""Handle config import from yaml."""
|
"""Handle config import from yaml."""
|
||||||
|
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Loading generic IP camera via configuration.yaml is deprecated, "
|
||||||
|
"it will be automatically imported. Once you have confirmed correct "
|
||||||
|
"operation, please remove 'generic' (IP camera) section(s) from "
|
||||||
|
"configuration.yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
async_create_issue(
|
||||||
|
self.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": "Generic IP Camera",
|
||||||
|
},
|
||||||
|
)
|
||||||
# abort if we've already got this one.
|
# abort if we've already got this one.
|
||||||
if self.check_for_existing(import_config):
|
if self.check_for_existing(import_config):
|
||||||
return self.async_abort(reason="already_exists")
|
return self.async_abort(reason="already_exists")
|
||||||
|
@ -34,8 +34,8 @@ from homeassistant.const import (
|
|||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
HTTP_BASIC_AUTHENTICATION,
|
HTTP_BASIC_AUTHENTICATION,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
@ -769,6 +769,13 @@ async def test_import(hass: HomeAssistant, fakeimg_png) -> None:
|
|||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Yaml Defined Name"
|
assert result["title"] == "Yaml Defined Name"
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
issue_registry = ir.async_get(hass)
|
||||||
|
issue = issue_registry.async_get_issue(
|
||||||
|
HOMEASSISTANT_DOMAIN, "deprecated_yaml_generic"
|
||||||
|
)
|
||||||
|
assert issue.translation_key == "deprecated_yaml"
|
||||||
|
|
||||||
# Any name defined in yaml should end up as the entity id.
|
# Any name defined in yaml should end up as the entity id.
|
||||||
assert hass.states.get("camera.yaml_defined_name")
|
assert hass.states.get("camera.yaml_defined_name")
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user