From ae20b3a67881e3af0aa4c9c69c123eec8b965f90 Mon Sep 17 00:00:00 2001 From: Christian Bilevits Date: Sun, 11 Oct 2020 16:57:21 +0200 Subject: [PATCH] Use common strings in ps4 config flow (#41623) --- homeassistant/components/ps4/config_flow.py | 4 ++-- homeassistant/components/ps4/strings.json | 18 +++++++++--------- tests/components/ps4/test_config_flow.py | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/ps4/config_flow.py b/homeassistant/components/ps4/config_flow.py index 17c0eb5838c..38e18d624ef 100644 --- a/homeassistant/components/ps4/config_flow.py +++ b/homeassistant/components/ps4/config_flow.py @@ -139,7 +139,7 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow): # If list is empty then all devices are configured. 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. if user_input is not None: @@ -154,7 +154,7 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow): ) if is_ready is False: - errors["base"] = "not_ready" + errors["base"] = "cannot_connect" elif is_login is False: errors["base"] = "login_failed" else: diff --git a/homeassistant/components/ps4/strings.json b/homeassistant/components/ps4/strings.json index c538852db56..f2a59830b59 100644 --- a/homeassistant/components/ps4/strings.json +++ b/homeassistant/components/ps4/strings.json @@ -7,33 +7,33 @@ }, "mode": { "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": { "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": { "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": { "region": "Region", "name": "[%key:common::config_flow::data::name%]", - "code": "PIN", + "code": "[%key:common::config_flow::data::pin%]", "ip_address": "[%key:common::config_flow::data::ip%]" } } }, "error": { "credential_timeout": "Credential service timed out. Press submit to restart.", - "not_ready": "PlayStation 4 is not on or connected to network.", - "login_failed": "Failed to pair to PlayStation 4. Verify PIN is correct.", - "no_ipaddress": "Enter the IP Address of the PlayStation 4 you would like to configure." + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "login_failed": "Failed to pair to PlayStation 4. Verify [%key:common::config_flow::data::pin%] is correct.", + "no_ipaddress": "Enter the [%key:common::config_flow::data::ip%] of the PlayStation 4 you would like to configure." }, "abort": { "credential_error": "Error fetching credentials.", - "no_devices_found": "No PlayStation 4 devices found on the network.", - "devices_configured": "All devices found are already configured.", + "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]", + "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_997_bind_error": "Could not bind to port 997. Refer to the [documentation](https://www.home-assistant.io/components/ps4/) for additional info." } diff --git a/tests/components/ps4/test_config_flow.py b/tests/components/ps4/test_config_flow.py index d7754cf1c8f..0febf142d02 100644 --- a/tests/components/ps4/test_config_flow.py +++ b/tests/components/ps4/test_config_flow.py @@ -284,7 +284,7 @@ async def test_duplicate_abort(hass): result["flow_id"], user_input=MOCK_AUTO ) 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): @@ -515,7 +515,7 @@ async def test_device_connection_error(hass): ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM 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):