mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +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],
|
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(
|
return self.async_show_form(
|
||||||
step_id="user", data_schema=CONFIG_SCHEMA, errors=errors
|
step_id="user", data_schema=CONFIG_SCHEMA, errors=errors
|
||||||
@ -238,7 +238,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
CONF_GEN: device_info[CONF_GEN],
|
CONF_GEN: device_info[CONF_GEN],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
errors["base"] = "firmware_not_fully_provisioned"
|
return self.async_abort(reason="firmware_not_fully_provisioned")
|
||||||
else:
|
else:
|
||||||
user_input = {}
|
user_input = {}
|
||||||
|
|
||||||
@ -333,21 +333,19 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
if not self.device_info[CONF_MODEL]:
|
if not self.device_info[CONF_MODEL]:
|
||||||
errors["base"] = "firmware_not_fully_provisioned"
|
return self.async_abort(reason="firmware_not_fully_provisioned")
|
||||||
model = "Shelly"
|
model = get_model_name(self.info)
|
||||||
else:
|
if user_input is not None:
|
||||||
model = get_model_name(self.info)
|
return self.async_create_entry(
|
||||||
if user_input is not None:
|
title=self.device_info["title"],
|
||||||
return self.async_create_entry(
|
data={
|
||||||
title=self.device_info["title"],
|
CONF_HOST: self.host,
|
||||||
data={
|
CONF_SLEEP_PERIOD: self.device_info[CONF_SLEEP_PERIOD],
|
||||||
CONF_HOST: self.host,
|
CONF_MODEL: self.device_info[CONF_MODEL],
|
||||||
CONF_SLEEP_PERIOD: self.device_info[CONF_SLEEP_PERIOD],
|
CONF_GEN: self.device_info[CONF_GEN],
|
||||||
CONF_MODEL: self.device_info[CONF_MODEL],
|
},
|
||||||
CONF_GEN: self.device_info[CONF_GEN],
|
)
|
||||||
},
|
self._set_confirm_only()
|
||||||
)
|
|
||||||
self._set_confirm_only()
|
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="confirm_discovery",
|
step_id="confirm_discovery",
|
||||||
|
@ -50,21 +50,21 @@
|
|||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"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_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
"invalid_host": "[%key:common::config_flow::error::invalid_host%]",
|
"invalid_host": "[%key:common::config_flow::error::invalid_host%]",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]",
|
"mac_address_mismatch": "The MAC address of the device does not match the one in the configuration, please reboot the device and try again.",
|
||||||
"firmware_not_fully_provisioned": "Device not fully provisioned. Please contact Shelly support",
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
"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."
|
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
"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_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||||
"reauth_unsuccessful": "Re-authentication was unsuccessful, please remove the integration and set it up again.",
|
"reauth_unsuccessful": "Re-authentication was unsuccessful, please remove the integration and set it up again.",
|
||||||
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
"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%]"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"device_automation": {
|
"device_automation": {
|
||||||
|
@ -348,8 +348,8 @@ async def test_form_missing_model_key(
|
|||||||
{CONF_HOST: "1.1.1.1"},
|
{CONF_HOST: "1.1.1.1"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] is FlowResultType.FORM
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["errors"] == {"base": "firmware_not_fully_provisioned"}
|
assert result2["reason"] == "firmware_not_fully_provisioned"
|
||||||
|
|
||||||
|
|
||||||
async def test_form_missing_model_key_auth_enabled(
|
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(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
result2["flow_id"], {CONF_PASSWORD: "1234"}
|
result2["flow_id"], {CONF_PASSWORD: "1234"}
|
||||||
)
|
)
|
||||||
assert result3["type"] is FlowResultType.FORM
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["errors"] == {"base": "firmware_not_fully_provisioned"}
|
assert result3["reason"] == "firmware_not_fully_provisioned"
|
||||||
|
|
||||||
|
|
||||||
async def test_form_missing_model_key_zeroconf(
|
async def test_form_missing_model_key_zeroconf(
|
||||||
@ -398,15 +398,8 @@ async def test_form_missing_model_key_zeroconf(
|
|||||||
data=DISCOVERY_INFO,
|
data=DISCOVERY_INFO,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
)
|
)
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["errors"] == {"base": "firmware_not_fully_provisioned"}
|
assert result["reason"] == "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"}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user