Use reference strings in Samsung TV config flow (#41248)
* Use reference strings in samsungtv config flow * Adjust samsungtv config flow tests
This commit is contained in:
parent
56f0a68c49
commit
78b4c3981f
5 changed files with 14 additions and 14 deletions
|
@ -22,7 +22,7 @@ from .const import (
|
|||
LOGGER,
|
||||
METHOD_LEGACY,
|
||||
RESULT_AUTH_MISSING,
|
||||
RESULT_NOT_SUCCESSFUL,
|
||||
RESULT_CANNOT_CONNECT,
|
||||
RESULT_NOT_SUPPORTED,
|
||||
RESULT_SUCCESS,
|
||||
VALUE_CONF_ID,
|
||||
|
@ -164,7 +164,7 @@ class SamsungTVLegacyBridge(SamsungTVBridge):
|
|||
return RESULT_NOT_SUPPORTED
|
||||
except OSError as err:
|
||||
LOGGER.debug("Failing config: %s, error: %s", config, err)
|
||||
return RESULT_NOT_SUCCESSFUL
|
||||
return RESULT_CANNOT_CONNECT
|
||||
|
||||
def _get_remote(self):
|
||||
"""Create or return a remote control instance."""
|
||||
|
@ -232,7 +232,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
|
|||
if result:
|
||||
return result
|
||||
|
||||
return RESULT_NOT_SUCCESSFUL
|
||||
return RESULT_CANNOT_CONNECT
|
||||
|
||||
def _send_key(self, key):
|
||||
"""Send the key using websocket protocol."""
|
||||
|
|
|
@ -31,7 +31,7 @@ from .const import (
|
|||
METHOD_LEGACY,
|
||||
METHOD_WEBSOCKET,
|
||||
RESULT_AUTH_MISSING,
|
||||
RESULT_NOT_SUCCESSFUL,
|
||||
RESULT_CANNOT_CONNECT,
|
||||
RESULT_SUCCESS,
|
||||
)
|
||||
|
||||
|
@ -87,10 +87,10 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
for method in SUPPORTED_METHODS:
|
||||
self._bridge = SamsungTVBridge.get_bridge(method, self._host)
|
||||
result = self._bridge.try_connect()
|
||||
if result != RESULT_NOT_SUCCESSFUL:
|
||||
if result != RESULT_CANNOT_CONNECT:
|
||||
return result
|
||||
LOGGER.debug("No working config found")
|
||||
return RESULT_NOT_SUCCESSFUL
|
||||
return RESULT_CANNOT_CONNECT
|
||||
|
||||
async def async_step_import(self, user_input=None):
|
||||
"""Handle configuration by yaml file."""
|
||||
|
|
|
@ -16,7 +16,7 @@ CONF_ON_ACTION = "turn_on_action"
|
|||
|
||||
RESULT_AUTH_MISSING = "auth_missing"
|
||||
RESULT_SUCCESS = "success"
|
||||
RESULT_NOT_SUCCESSFUL = "not_successful"
|
||||
RESULT_CANNOT_CONNECT = "cannot_connect"
|
||||
RESULT_NOT_SUPPORTED = "not_supported"
|
||||
|
||||
METHOD_LEGACY = "legacy"
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
},
|
||||
"abort": {
|
||||
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
|
||||
"already_configured": "This Samsung TV is already configured.",
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"auth_missing": "Home Assistant is not authorized to connect to this Samsung TV. Please check your TV's settings to authorize Home Assistant.",
|
||||
"not_successful": "Unable to connect to this Samsung TV device.",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"not_supported": "This Samsung TV device is currently not supported."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ async def test_user_not_successful(hass):
|
|||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_successful"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_user_not_successful_2(hass):
|
||||
|
@ -229,7 +229,7 @@ async def test_user_not_successful_2(hass):
|
|||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_successful"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_user_already_configured(hass, remote):
|
||||
|
@ -389,7 +389,7 @@ async def test_ssdp_not_successful(hass):
|
|||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_successful"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_ssdp_not_successful_2(hass):
|
||||
|
@ -416,7 +416,7 @@ async def test_ssdp_not_successful_2(hass):
|
|||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_successful"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_ssdp_already_in_progress(hass, remote):
|
||||
|
@ -570,7 +570,7 @@ async def test_autodetect_none(hass, remote, remotews):
|
|||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "not_successful"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
assert remote.call_count == 1
|
||||
assert remote.call_args_list == [
|
||||
call(AUTODETECT_LEGACY),
|
||||
|
|
Loading…
Add table
Reference in a new issue