Switch ezviz to use integration discovery (#66579)
This commit is contained in:
parent
38b9bea9a3
commit
e0cee22b8a
3 changed files with 13 additions and 9 deletions
|
@ -10,9 +10,9 @@ from homeassistant.components import ffmpeg
|
|||
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
|
||||
from homeassistant.components.ffmpeg import get_ffmpeg_manager
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_DISCOVERY,
|
||||
SOURCE_IGNORE,
|
||||
SOURCE_IMPORT,
|
||||
SOURCE_INTEGRATION_DISCOVERY,
|
||||
ConfigEntry,
|
||||
)
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME
|
||||
|
@ -151,7 +151,7 @@ async def async_setup_entry(
|
|||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DISCOVERY},
|
||||
context={"source": SOURCE_INTEGRATION_DISCOVERY},
|
||||
data={
|
||||
ATTR_SERIAL: camera,
|
||||
CONF_IP_ADDRESS: value["local_ip"],
|
||||
|
|
|
@ -259,7 +259,7 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
step_id="user_custom_url", data_schema=data_schema_custom_url, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_discovery(self, discovery_info):
|
||||
async def async_step_integration_discovery(self, discovery_info):
|
||||
"""Handle a flow for discovered camera without rtsp config entry."""
|
||||
|
||||
await self.async_set_unique_id(discovery_info[ATTR_SERIAL])
|
||||
|
|
|
@ -19,7 +19,11 @@ from homeassistant.components.ezviz.const import (
|
|||
DEFAULT_TIMEOUT,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_DISCOVERY, SOURCE_IMPORT, SOURCE_USER
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IMPORT,
|
||||
SOURCE_INTEGRATION_DISCOVERY,
|
||||
SOURCE_USER,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_CUSTOMIZE,
|
||||
CONF_IP_ADDRESS,
|
||||
|
@ -175,7 +179,7 @@ async def test_step_discovery_abort_if_cloud_account_missing(hass):
|
|||
"""Test discovery and confirm step, abort if cloud account was removed."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_DISCOVERY}, data=DISCOVERY_INFO
|
||||
DOMAIN, context={"source": SOURCE_INTEGRATION_DISCOVERY}, data=DISCOVERY_INFO
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
@ -194,7 +198,7 @@ async def test_step_discovery_abort_if_cloud_account_missing(hass):
|
|||
assert result["reason"] == "ezviz_cloud_account_missing"
|
||||
|
||||
|
||||
async def test_async_step_discovery(
|
||||
async def test_async_step_integration_discovery(
|
||||
hass, ezviz_config_flow, ezviz_test_rtsp_config_flow
|
||||
):
|
||||
"""Test discovery and confirm step."""
|
||||
|
@ -202,7 +206,7 @@ async def test_async_step_discovery(
|
|||
await init_integration(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_DISCOVERY}, data=DISCOVERY_INFO
|
||||
DOMAIN, context={"source": SOURCE_INTEGRATION_DISCOVERY}, data=DISCOVERY_INFO
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
@ -353,7 +357,7 @@ async def test_discover_exception_step1(
|
|||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DISCOVERY},
|
||||
context={"source": SOURCE_INTEGRATION_DISCOVERY},
|
||||
data={ATTR_SERIAL: "C66666", CONF_IP_ADDRESS: "test-ip"},
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
|
@ -428,7 +432,7 @@ async def test_discover_exception_step3(
|
|||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_DISCOVERY},
|
||||
context={"source": SOURCE_INTEGRATION_DISCOVERY},
|
||||
data={ATTR_SERIAL: "C66666", CONF_IP_ADDRESS: "test-ip"},
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
|
|
Loading…
Add table
Reference in a new issue