Use common strings in ps4 config flow (#41623)

This commit is contained in:
Christian Bilevits 2020-10-11 16:57:21 +02:00 committed by GitHub
parent ffd25fb2ce
commit ae20b3a678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -139,7 +139,7 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
# If list is empty then all devices are configured. # If list is empty then all devices are configured.
if not self.device_list: if not self.device_list:
return self.async_abort(reason="devices_configured") return self.async_abort(reason="already_configured")
# Login to PS4 with user data. # Login to PS4 with user data.
if user_input is not None: if user_input is not None:
@ -154,7 +154,7 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
) )
if is_ready is False: if is_ready is False:
errors["base"] = "not_ready" errors["base"] = "cannot_connect"
elif is_login is False: elif is_login is False:
errors["base"] = "login_failed" errors["base"] = "login_failed"
else: else:

View File

@ -7,33 +7,33 @@
}, },
"mode": { "mode": {
"title": "PlayStation 4", "title": "PlayStation 4",
"description": "Select mode for configuration. The IP Address field can be left blank if selecting Auto Discovery, as devices will be automatically discovered.", "description": "Select mode for configuration. The [%key:common::config_flow::data::ip%] field can be left blank if selecting Auto Discovery, as devices will be automatically discovered.",
"data": { "data": {
"mode": "Config Mode", "mode": "Config Mode",
"ip_address": "IP Address (Leave empty if using Auto Discovery)." "ip_address": "[%key:common::config_flow::data::ip%] (Leave empty if using Auto Discovery)."
} }
}, },
"link": { "link": {
"title": "PlayStation 4", "title": "PlayStation 4",
"description": "Enter your PlayStation 4 information. For 'PIN', navigate to 'Settings' on your PlayStation 4 console. Then navigate to 'Mobile App Connection Settings' and select 'Add Device'. Enter the PIN that is displayed. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info.", "description": "Enter your PlayStation 4 information. For [%key:common::config_flow::data::pin%], navigate to 'Settings' on your PlayStation 4 console. Then navigate to 'Mobile App Connection Settings' and select 'Add Device'. Enter the [%key:common::config_flow::data::pin%] that is displayed. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info.",
"data": { "data": {
"region": "Region", "region": "Region",
"name": "[%key:common::config_flow::data::name%]", "name": "[%key:common::config_flow::data::name%]",
"code": "PIN", "code": "[%key:common::config_flow::data::pin%]",
"ip_address": "[%key:common::config_flow::data::ip%]" "ip_address": "[%key:common::config_flow::data::ip%]"
} }
} }
}, },
"error": { "error": {
"credential_timeout": "Credential service timed out. Press submit to restart.", "credential_timeout": "Credential service timed out. Press submit to restart.",
"not_ready": "PlayStation 4 is not on or connected to network.", "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"login_failed": "Failed to pair to PlayStation 4. Verify PIN is correct.", "login_failed": "Failed to pair to PlayStation 4. Verify [%key:common::config_flow::data::pin%] is correct.",
"no_ipaddress": "Enter the IP Address of the PlayStation 4 you would like to configure." "no_ipaddress": "Enter the [%key:common::config_flow::data::ip%] of the PlayStation 4 you would like to configure."
}, },
"abort": { "abort": {
"credential_error": "Error fetching credentials.", "credential_error": "Error fetching credentials.",
"no_devices_found": "No PlayStation 4 devices found on the network.", "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]",
"devices_configured": "All devices found are already configured.", "already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"port_987_bind_error": "Could not bind to port 987. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info.", "port_987_bind_error": "Could not bind to port 987. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info.",
"port_997_bind_error": "Could not bind to port 997. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info." "port_997_bind_error": "Could not bind to port 997. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info."
} }

View File

@ -284,7 +284,7 @@ async def test_duplicate_abort(hass):
result["flow_id"], user_input=MOCK_AUTO result["flow_id"], user_input=MOCK_AUTO
) )
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "devices_configured" assert result["reason"] == "already_configured"
async def test_additional_device(hass): async def test_additional_device(hass):
@ -515,7 +515,7 @@ async def test_device_connection_error(hass):
) )
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "not_ready"} assert result["errors"] == {"base": "cannot_connect"}
async def test_manual_mode_no_ip_error(hass): async def test_manual_mode_no_ip_error(hass):