Edinburgh defeated the Sharks 33-28 in a close United Rugby Championship clash, securing a vital five-point home victory at their fortress.