mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Abort Shelly flows if the device is not fully provisioned (#143652)
* Abort flows if the device is not fully provisioned * Update tests
This commit is contained in:
parent
cb0523660d
commit
5b503f21d7
@ -198,7 +198,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
CONF_GEN: device_info[CONF_GEN],
|
||||
},
|
||||
)
|
||||
errors["base"] = "firmware_not_fully_provisioned"
|
||||
return self.async_abort(reason="firmware_not_fully_provisioned")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=CONFIG_SCHEMA, errors=errors
|
||||
@ -238,7 +238,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
CONF_GEN: device_info[CONF_GEN],
|
||||
},
|
||||
)
|
||||
errors["base"] = "firmware_not_fully_provisioned"
|
||||
return self.async_abort(reason="firmware_not_fully_provisioned")
|
||||
else:
|
||||
user_input = {}
|
||||
|
||||
@ -333,21 +333,19 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
if not self.device_info[CONF_MODEL]:
|
||||
errors["base"] = "firmware_not_fully_provisioned"
|
||||
model = "Shelly"
|
||||
else:
|
||||
model = get_model_name(self.info)
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
title=self.device_info["title"],
|
||||
data={
|
||||
CONF_HOST: self.host,
|
||||
CONF_SLEEP_PERIOD: self.device_info[CONF_SLEEP_PERIOD],
|
||||
CONF_MODEL: self.device_info[CONF_MODEL],
|
||||
CONF_GEN: self.device_info[CONF_GEN],
|
||||
},
|
||||
)
|
||||
self._set_confirm_only()
|
||||
return self.async_abort(reason="firmware_not_fully_provisioned")
|
||||
model = get_model_name(self.info)
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
title=self.device_info["title"],
|
||||
data={
|
||||
CONF_HOST: self.host,
|
||||
CONF_SLEEP_PERIOD: self.device_info[CONF_SLEEP_PERIOD],
|
||||
CONF_MODEL: self.device_info[CONF_MODEL],
|
||||
CONF_GEN: self.device_info[CONF_GEN],
|
||||
},
|
||||
)
|
||||
self._set_confirm_only()
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="confirm_discovery",
|
||||
|
@ -50,21 +50,21 @@
|
||||
},
|
||||
"error": {
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"custom_port_not_supported": "Gen1 device does not support custom port.",
|
||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||
"invalid_host": "[%key:common::config_flow::error::invalid_host%]",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]",
|
||||
"firmware_not_fully_provisioned": "Device not fully provisioned. Please contact Shelly support",
|
||||
"custom_port_not_supported": "Gen1 device does not support custom port.",
|
||||
"mac_address_mismatch": "The MAC address of the device does not match the one in the configuration, please reboot the device and try again."
|
||||
"mac_address_mismatch": "The MAC address of the device does not match the one in the configuration, please reboot the device and try again.",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"another_device": "Re-configuration was unsuccessful, the IP address/hostname of another Shelly device was used.",
|
||||
"firmware_not_fully_provisioned": "Device not fully provisioned. Please contact Shelly support",
|
||||
"ipv6_not_supported": "IPv6 is not supported.",
|
||||
"mac_address_mismatch": "[%key:component::shelly::config::error::mac_address_mismatch%]",
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||
"reauth_unsuccessful": "Re-authentication was unsuccessful, please remove the integration and set it up again.",
|
||||
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
||||
"another_device": "Re-configuration was unsuccessful, the IP address/hostname of another Shelly device was used.",
|
||||
"ipv6_not_supported": "IPv6 is not supported.",
|
||||
"mac_address_mismatch": "[%key:component::shelly::config::error::mac_address_mismatch%]"
|
||||
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]"
|
||||
}
|
||||
},
|
||||
"device_automation": {
|
||||
|
@ -348,8 +348,8 @@ async def test_form_missing_model_key(
|
||||
{CONF_HOST: "1.1.1.1"},
|
||||
)
|
||||
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "firmware_not_fully_provisioned"}
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "firmware_not_fully_provisioned"
|
||||
|
||||
|
||||
async def test_form_missing_model_key_auth_enabled(
|
||||
@ -378,8 +378,8 @@ async def test_form_missing_model_key_auth_enabled(
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result2["flow_id"], {CONF_PASSWORD: "1234"}
|
||||
)
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "firmware_not_fully_provisioned"}
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "firmware_not_fully_provisioned"
|
||||
|
||||
|
||||
async def test_form_missing_model_key_zeroconf(
|
||||
@ -398,15 +398,8 @@ async def test_form_missing_model_key_zeroconf(
|
||||
data=DISCOVERY_INFO,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "firmware_not_fully_provisioned"}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{},
|
||||
)
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "firmware_not_fully_provisioned"}
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "firmware_not_fully_provisioned"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user