mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Use reference strings in Wled (#40969)
This commit is contained in:
parent
8dae2f4308
commit
68aafd4d23
@ -36,7 +36,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
) -> Dict[str, Any]:
|
||||
"""Handle zeroconf discovery."""
|
||||
if user_input is None:
|
||||
return self.async_abort(reason="connection_error")
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
# Hostname is format: wled-livingroom.local.
|
||||
host = user_input["hostname"].rstrip(".")
|
||||
@ -86,8 +86,8 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
device = await wled.update()
|
||||
except WLEDConnectionError:
|
||||
if source == SOURCE_ZEROCONF:
|
||||
return self.async_abort(reason="connection_error")
|
||||
return self._show_setup_form({"base": "connection_error"})
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
return self._show_setup_form({"base": "cannot_connect"})
|
||||
user_input[CONF_MAC] = device.info.mac_address
|
||||
|
||||
# Check if already configured
|
||||
|
@ -14,11 +14,11 @@
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"connection_error": "Failed to connect to WLED device."
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "This WLED device is already configured.",
|
||||
"connection_error": "Failed to connect to WLED device."
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ async def test_connection_error(
|
||||
data={CONF_HOST: "example.com"},
|
||||
)
|
||||
|
||||
assert result["errors"] == {"base": "connection_error"}
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
assert result["step_id"] == "user"
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
||||
@ -93,7 +93,7 @@ async def test_zeroconf_connection_error(
|
||||
data={"host": "192.168.1.123", "hostname": "example.local.", "properties": {}},
|
||||
)
|
||||
|
||||
assert result["reason"] == "connection_error"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ async def test_zeroconf_confirm_connection_error(
|
||||
data={"host": "192.168.1.123", "hostname": "example.com.", "properties": {}},
|
||||
)
|
||||
|
||||
assert result["reason"] == "connection_error"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ async def test_zeroconf_no_data(
|
||||
flow.hass = hass
|
||||
result = await flow.async_step_zeroconf()
|
||||
|
||||
assert result["reason"] == "connection_error"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user