You need to determine whether the time you were away would be considered residing elsewhere.
If you were only away for a vacation or other short absence, you can count it as time you lived at home, even if you rented out your home while you were gone.
If you or your spouse are a member of the Uniformed Services or the Foreign Service, or an employee of the intelligence community in the United States, you can choose to suspend the 5-year residency test if you're not residing in the home because of
qualified extended duty. This period of suspension can't last more than 10 years.
For example: John's qualified extended duty kept him from living in his home and lasted 7 years. At the end of the 7 years, John sells his home. John chooses to suspend the 7 years he was on qualified extended duty. With the suspension, John must only have lived in the home for two years or more during the 5 years before he was on qualified extended duty.