Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use common strings in opentherm_gw config flow #42211

Merged
merged 5 commits into from Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions homeassistant/components/opentherm_gw/config_flow.py
Expand Up @@ -58,10 +58,8 @@ async def test_connection():

try:
res = await asyncio.wait_for(test_connection(), timeout=10)
except asyncio.TimeoutError:
return self._show_form({"base": "timeout"})
except SerialException:
return self._show_form({"base": "serial_error"})
except (asyncio.TimeoutError, SerialException):
return self._show_form({"base": "cannot_connect"})

if res:
return self._create_entry(gw_id, name, device)
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/opentherm_gw/strings.json
Expand Up @@ -11,10 +11,9 @@
}
},
"error": {
"already_configured": "Gateway already configured",
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"id_exists": "Gateway id already exists",
"serial_error": "Error connecting to device",
"timeout": "Connection attempt timed out"
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
}
},
"options": {
Expand Down
4 changes: 2 additions & 2 deletions tests/components/opentherm_gw/test_config_flow.py
Expand Up @@ -148,7 +148,7 @@ async def test_form_connection_timeout(hass):
)

assert result2["type"] == "form"
assert result2["errors"] == {"base": "timeout"}
assert result2["errors"] == {"base": "cannot_connect"}
assert len(mock_connect.mock_calls) == 1


Expand All @@ -164,7 +164,7 @@ async def test_form_connection_error(hass):
)

assert result2["type"] == "form"
assert result2["errors"] == {"base": "serial_error"}
assert result2["errors"] == {"base": "cannot_connect"}
assert len(mock_connect.mock_calls) == 1


Expand Down