Greig Laidlaw landed a penalty to reduce the deficit but Ruaridh Jackson's breakaway try and two Pete Horne penalties just before the break gave the Warriors a 16-3 lead.
Henry Pyrgos was ruled by the TMO to have legally touched down in the 55th minute as the Warriors stormed ahead but Edinburgh threatened a comeback with tries from Roddy Grant and Tim Visser, both converted by Laidlaw.
However the Warriors held on for a 44-31 aggregate victory and it could have been more comprehensive had a Dougie Hall try not been ruled out and Stuart Hogg not dropped the ball over the try line, and Townsend feels there is much more to come from his side.
"We know we're not the finished article," said Townsend.
"We've got a lot to work on - one is playing for 80 minutes, another is our discipline, which has got to improve.
"It's a continual process. We know we have to kick on now.
"The pulse rate did go up. Edinburgh certainly got the momentum in that last period, but I know we've got a very good defence.
"To get three tries was great and to get the win and retain the cup was excellent.
"We were disappointed we didn't get the fourth try.
"There was one that was disallowed which would've been a cracking try - I'd love to work out why that was disallowed."