diff --git a/homeassistant/components/samsungtv/bridge.py b/homeassistant/components/samsungtv/bridge.py index 02a36915dc6a66b595565b6c5e13451643d3eaa8..99e9f87741302a7386cddfcf0ee4bc6743cf182d 100644 --- a/homeassistant/components/samsungtv/bridge.py +++ b/homeassistant/components/samsungtv/bridge.py @@ -422,8 +422,7 @@ class SamsungTVWSBridge(SamsungTVBridge): for _ in range(retry_count + 1): try: if remote := await self._async_get_remote(): - for command in commands: - await remote.send_command(command) + await remote.send_command(commands) break except ( BrokenPipeError, diff --git a/tests/components/samsungtv/test_media_player.py b/tests/components/samsungtv/test_media_player.py index bc693918b5fd78da4d9bfa5b37a0c6fdf8047535..e5520098a4ad0207d40b805f8e3f51aababa6a20 100644 --- a/tests/components/samsungtv/test_media_player.py +++ b/tests/components/samsungtv/test_media_player.py @@ -641,9 +641,10 @@ async def test_turn_off_websocket( ) # key called assert remotews.send_command.call_count == 1 - command = remotews.send_command.call_args_list[0].args[0] - assert isinstance(command, SendRemoteKey) - assert command.params["DataOfCmd"] == "KEY_POWER" + commands = remotews.send_command.call_args_list[0].args[0] + assert len(commands) == 1 + assert isinstance(commands[0], SendRemoteKey) + assert commands[0].params["DataOfCmd"] == "KEY_POWER" # commands not sent : power off in progress remotews.send_command.reset_mock() @@ -678,18 +679,17 @@ async def test_turn_off_websocket_frame( DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key called - assert remotews.send_command.call_count == 3 - command = remotews.send_command.call_args_list[0].args[0] - assert isinstance(command, SendRemoteKey) - assert command.params["Cmd"] == "Press" - assert command.params["DataOfCmd"] == "KEY_POWER" - command = remotews.send_command.call_args_list[1].args[0] - assert isinstance(command, SamsungTVSleepCommand) - assert command.delay == 3 - command = remotews.send_command.call_args_list[2].args[0] - assert isinstance(command, SendRemoteKey) - assert command.params["Cmd"] == "Release" - assert command.params["DataOfCmd"] == "KEY_POWER" + assert remotews.send_command.call_count == 1 + commands = remotews.send_command.call_args_list[0].args[0] + assert len(commands) == 3 + assert isinstance(commands[0], SendRemoteKey) + assert commands[0].params["Cmd"] == "Press" + assert commands[0].params["DataOfCmd"] == "KEY_POWER" + assert isinstance(commands[1], SamsungTVSleepCommand) + assert commands[1].delay == 3 + assert isinstance(commands[2], SendRemoteKey) + assert commands[2].params["Cmd"] == "Release" + assert commands[2].params["DataOfCmd"] == "KEY_POWER" async def test_turn_off_legacy(hass: HomeAssistant, remote: Mock) -> None: @@ -1023,9 +1023,10 @@ async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None: True, ) assert remotews.send_command.call_count == 1 - command = remotews.send_command.call_args_list[0].args[0] - assert isinstance(command, ChannelEmitCommand) - assert command.params["data"]["appId"] == "3201608010191" + commands = remotews.send_command.call_args_list[0].args[0] + assert len(commands) == 1 + assert isinstance(commands[0], ChannelEmitCommand) + assert commands[0].params["data"]["appId"] == "3201608010191" async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None: @@ -1040,6 +1041,7 @@ async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None: True, ) assert remotews.send_command.call_count == 1 - command = remotews.send_command.call_args_list[0].args[0] - assert isinstance(command, ChannelEmitCommand) - assert command.params["data"]["appId"] == "3201608010191" + commands = remotews.send_command.call_args_list[0].args[0] + assert len(commands) == 1 + assert isinstance(commands[0], ChannelEmitCommand) + assert commands[0].params["data"]["appId"] == "3201608010191"