In this paper, we investigate the problem of minimizing the sum of energy cost and thermal discomfort cost in a long-term time horizon for a sustainable smart home with a Heating, Ventilation, and Air Conditioning (HVAC) load. Specifically, we first formulate a stochastic program to minimize the time average expected total cost with the consideration of uncertainties in electricity price, outdoor temperature, renewable generation output, electrical demand, the most comfortable temperature level, and home occupancy state. Then, we propose an online energy management algorithm based on the framework of Lyapunov optimization techniques without the need to predict any system parameters. The key idea of the proposed algorithm is to construct and stabilize four queues associated with indoor temperature, electric vehicle charging, and energy storage. Moreover, we theoretically analyze the feasibility and performance guarantee of the proposed algorithm. Extensive simulations based on real-world traces show the effectiveness of the proposed algorithm.