mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Use constants in control4 config flow (#58602)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
b368476429
commit
1e8ccb47ce
@ -16,6 +16,7 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import STEP_ID_INIT, STEP_ID_USER
|
||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
@ -96,9 +97,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if user_input is not None:
|
||||
|
||||
hub = Control4Validator(
|
||||
user_input["host"],
|
||||
user_input["username"],
|
||||
user_input["password"],
|
||||
user_input[CONF_HOST],
|
||||
user_input[CONF_USERNAME],
|
||||
user_input[CONF_PASSWORD],
|
||||
self.hass,
|
||||
)
|
||||
try:
|
||||
@ -123,15 +124,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_create_entry(
|
||||
title=controller_unique_id,
|
||||
data={
|
||||
CONF_HOST: user_input["host"],
|
||||
CONF_USERNAME: user_input["username"],
|
||||
CONF_PASSWORD: user_input["password"],
|
||||
CONF_HOST: user_input[CONF_HOST],
|
||||
CONF_USERNAME: user_input[CONF_USERNAME],
|
||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
||||
CONF_CONTROLLER_UNIQUE_ID: controller_unique_id,
|
||||
},
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||
step_id=STEP_ID_USER, data_schema=DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@ -163,7 +164,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
): vol.All(cv.positive_int, vol.Clamp(min=MIN_SCAN_INTERVAL)),
|
||||
}
|
||||
)
|
||||
return self.async_show_form(step_id="init", data_schema=data_schema)
|
||||
return self.async_show_form(step_id=STEP_ID_INIT, data_schema=data_schema)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
|
@ -21,6 +21,7 @@ RESULT_TYPE_EXTERNAL_STEP_DONE = "external_done"
|
||||
RESULT_TYPE_SHOW_PROGRESS = "progress"
|
||||
RESULT_TYPE_SHOW_PROGRESS_DONE = "progress_done"
|
||||
|
||||
STEP_ID_INIT: Final = "init"
|
||||
STEP_ID_USER: Final = "user"
|
||||
|
||||
# Event that is fired when a flow is progressed via external or progress source.
|
||||
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.data_entry_flow import STEP_ID_INIT
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@ -166,7 +167,7 @@ async def test_option_flow(hass):
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "init"
|
||||
assert result["step_id"] == STEP_ID_INIT
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
@ -186,7 +187,7 @@ async def test_option_flow_defaults(hass):
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "init"
|
||||
assert result["step_id"] == STEP_ID_INIT
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
|
Loading…
x
Reference in New Issue
Block a user