Disable config flow progress in peco config flow (#105222)
This commit is contained in:
parent
f1169e0a0d
commit
d679764d3b
2 changed files with 2 additions and 46 deletions
|
@ -33,7 +33,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
meter_verification: bool = False
|
||||
meter_data: dict[str, str] = {}
|
||||
meter_error: dict[str, str] = {}
|
||||
|
||||
|
@ -53,17 +52,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
except HttpError:
|
||||
self.meter_error = {"phone_number": "http_error", "type": "error"}
|
||||
|
||||
self.hass.async_create_task(
|
||||
self.hass.config_entries.flow.async_configure(flow_id=self.flow_id)
|
||||
)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle the initial step."""
|
||||
if self.meter_verification is True:
|
||||
return self.async_show_progress_done(next_step_id="finish_smart_meter")
|
||||
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
|
@ -86,20 +78,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
await self.async_set_unique_id(f"{county}-{phone_number}")
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
self.meter_verification = True
|
||||
|
||||
if self.meter_error is not None:
|
||||
# Clear any previous errors, since the user may have corrected them
|
||||
self.meter_error = {}
|
||||
|
||||
self.hass.async_create_task(self._verify_meter(phone_number))
|
||||
await self._verify_meter(phone_number)
|
||||
|
||||
self.meter_data = user_input
|
||||
|
||||
return self.async_show_progress(
|
||||
step_id="user",
|
||||
progress_action="verifying_meter",
|
||||
)
|
||||
return await self.async_step_finish_smart_meter()
|
||||
|
||||
async def async_step_finish_smart_meter(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
|
@ -107,7 +94,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""Handle the finish smart meter step."""
|
||||
if "phone_number" in self.meter_error:
|
||||
if self.meter_error["type"] == "error":
|
||||
self.meter_verification = False
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=STEP_USER_DATA_SCHEMA,
|
||||
|
|
|
@ -78,12 +78,6 @@ async def test_meter_value_error(hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "user"
|
||||
assert result["progress_action"] == "verifying_meter"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"phone_number": "invalid_phone_number"}
|
||||
|
@ -107,12 +101,6 @@ async def test_incompatible_meter_error(hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "user"
|
||||
assert result["progress_action"] == "verifying_meter"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["reason"] == "incompatible_meter"
|
||||
|
||||
|
@ -135,12 +123,6 @@ async def test_unresponsive_meter_error(hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "user"
|
||||
assert result["progress_action"] == "verifying_meter"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"phone_number": "unresponsive_meter"}
|
||||
|
@ -164,12 +146,6 @@ async def test_meter_http_error(hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "user"
|
||||
assert result["progress_action"] == "verifying_meter"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"phone_number": "http_error"}
|
||||
|
@ -193,12 +169,6 @@ async def test_smart_meter(hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "user"
|
||||
assert result["progress_action"] == "verifying_meter"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Philadelphia - 1234567890"
|
||||
assert result["data"]["phone_number"] == "1234567890"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue