mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Cleanup SamsungTV following dependency bump (#68562)
* send_command -> send_commands * Remove TODO Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
c3f0bd45a4
commit
df6cc94b25
@ -468,7 +468,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
|
|||||||
for _ in range(retry_count + 1):
|
for _ in range(retry_count + 1):
|
||||||
try:
|
try:
|
||||||
if remote := await self._async_get_remote():
|
if remote := await self._async_get_remote():
|
||||||
await remote.send_command(commands)
|
await remote.send_commands(commands)
|
||||||
break
|
break
|
||||||
except (
|
except (
|
||||||
BrokenPipeError,
|
BrokenPipeError,
|
||||||
@ -712,12 +712,7 @@ class SamsungTVEncryptedBridge(SamsungTVBridge):
|
|||||||
timeout=TIMEOUT_WEBSOCKET,
|
timeout=TIMEOUT_WEBSOCKET,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
# pylint:disable=[fixme]
|
await self._remote.start_listening()
|
||||||
# TODO: remove secondary timeout when library is bumped
|
|
||||||
# See https://github.com/xchwarze/samsung-tv-ws-api/pull/82
|
|
||||||
await asyncio.wait_for(
|
|
||||||
self._remote.start_listening(), TIMEOUT_WEBSOCKET
|
|
||||||
)
|
|
||||||
except (WebSocketException, AsyncioTimeoutError, OSError) as err:
|
except (WebSocketException, AsyncioTimeoutError, OSError) as err:
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Failed to get remote for %s: %s", self.host, err.__repr__()
|
"Failed to get remote for %s: %s", self.host, err.__repr__()
|
||||||
|
@ -593,7 +593,7 @@ async def test_send_key_unhandled_response(hass: HomeAssistant, remote: Mock) ->
|
|||||||
async def test_send_key_websocketexception(hass: HomeAssistant, remotews: Mock) -> None:
|
async def test_send_key_websocketexception(hass: HomeAssistant, remotews: Mock) -> None:
|
||||||
"""Testing unhandled response exception."""
|
"""Testing unhandled response exception."""
|
||||||
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
||||||
remotews.send_command = Mock(side_effect=WebSocketException("Boom"))
|
remotews.send_commands = Mock(side_effect=WebSocketException("Boom"))
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
@ -619,7 +619,7 @@ async def test_send_key_websocketexception_encrypted(
|
|||||||
async def test_send_key_os_error_ws(hass: HomeAssistant, remotews: Mock) -> None:
|
async def test_send_key_os_error_ws(hass: HomeAssistant, remotews: Mock) -> None:
|
||||||
"""Testing unhandled response exception."""
|
"""Testing unhandled response exception."""
|
||||||
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
||||||
remotews.send_command = Mock(side_effect=OSError("Boom"))
|
remotews.send_commands = Mock(side_effect=OSError("Boom"))
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
@ -744,20 +744,20 @@ async def test_turn_off_websocket(
|
|||||||
):
|
):
|
||||||
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
||||||
|
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_commands.reset_mock()
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
# key called
|
# key called
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_commands.call_count == 1
|
||||||
commands = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_commands.call_args_list[0].args[0]
|
||||||
assert len(commands) == 1
|
assert len(commands) == 1
|
||||||
assert isinstance(commands[0], SendRemoteKey)
|
assert isinstance(commands[0], SendRemoteKey)
|
||||||
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
|
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
|
||||||
|
|
||||||
# commands not sent : power off in progress
|
# commands not sent : power off in progress
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_commands.reset_mock()
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
@ -769,7 +769,7 @@ async def test_turn_off_websocket(
|
|||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
assert "TV is powering off, not sending launch_app command" in caplog.text
|
assert "TV is powering off, not sending launch_app command" in caplog.text
|
||||||
remotews.send_command.assert_not_called()
|
remotews.send_commands.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
async def test_turn_off_websocket_frame(
|
async def test_turn_off_websocket_frame(
|
||||||
@ -783,14 +783,14 @@ async def test_turn_off_websocket_frame(
|
|||||||
):
|
):
|
||||||
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
||||||
|
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_commands.reset_mock()
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
# key called
|
# key called
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_commands.call_count == 1
|
||||||
commands = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_commands.call_args_list[0].args[0]
|
||||||
assert len(commands) == 3
|
assert len(commands) == 3
|
||||||
assert isinstance(commands[0], SendRemoteKey)
|
assert isinstance(commands[0], SendRemoteKey)
|
||||||
assert commands[0].params["Cmd"] == "Press"
|
assert commands[0].params["Cmd"] == "Press"
|
||||||
@ -1157,7 +1157,7 @@ async def test_select_source_invalid_source(hass: HomeAssistant) -> None:
|
|||||||
async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None:
|
async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None:
|
||||||
"""Test for play_media."""
|
"""Test for play_media."""
|
||||||
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_commands.reset_mock()
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -1169,8 +1169,8 @@ async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None:
|
|||||||
},
|
},
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_commands.call_count == 1
|
||||||
commands = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_commands.call_args_list[0].args[0]
|
||||||
assert len(commands) == 1
|
assert len(commands) == 1
|
||||||
assert isinstance(commands[0], ChannelEmitCommand)
|
assert isinstance(commands[0], ChannelEmitCommand)
|
||||||
assert commands[0].params["data"]["appId"] == "3201608010191"
|
assert commands[0].params["data"]["appId"] == "3201608010191"
|
||||||
@ -1179,7 +1179,7 @@ async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None:
|
|||||||
async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
|
async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
|
||||||
"""Test for select_source."""
|
"""Test for select_source."""
|
||||||
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
await setup_samsungtv(hass, MOCK_CONFIGWS)
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_commands.reset_mock()
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -1187,8 +1187,8 @@ async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
|
|||||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_INPUT_SOURCE: "Deezer"},
|
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_INPUT_SOURCE: "Deezer"},
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_commands.call_count == 1
|
||||||
commands = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_commands.call_args_list[0].args[0]
|
||||||
assert len(commands) == 1
|
assert len(commands) == 1
|
||||||
assert isinstance(commands[0], ChannelEmitCommand)
|
assert isinstance(commands[0], ChannelEmitCommand)
|
||||||
assert commands[0].params["data"]["appId"] == "3201608010191"
|
assert commands[0].params["data"]["appId"] == "3201608010191"
|
||||||
@ -1203,7 +1203,7 @@ async def test_websocket_unsupported_remote_control(
|
|||||||
assert entry.data[CONF_METHOD] == METHOD_WEBSOCKET
|
assert entry.data[CONF_METHOD] == METHOD_WEBSOCKET
|
||||||
assert entry.data[CONF_PORT] == 8001
|
assert entry.data[CONF_PORT] == 8001
|
||||||
|
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_commands.reset_mock()
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
@ -1217,8 +1217,8 @@ async def test_websocket_unsupported_remote_control(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# key called
|
# key called
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_commands.call_count == 1
|
||||||
commands = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_commands.call_args_list[0].args[0]
|
||||||
assert len(commands) == 1
|
assert len(commands) == 1
|
||||||
assert isinstance(commands[0], SendRemoteKey)
|
assert isinstance(commands[0], SendRemoteKey)
|
||||||
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
|
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user