Heat pumps for space heating or cooling and water heating