To minimize electricity fee of a residential user, a framework and a scheduling algorithm for home energy management system (HEMS) in smart grid are proposed. The algorithm controls loads, plug-in hybrid electric vehicle(PHEV), and energy storage system according to predicted outdoor temperature, renewable resource power output, day-ahead electricity price, and user preferences. In this algorithm, the PHEV can supply stored power to other loads through V2H(vehicle to home, V2H) in high electricity price periods. Scenario analysis technique is utilized to cope with the uncertainty due to the error of predicted outdoor temperature and renewable resource power output. The effectiveness of the algorithm is verified by simulation, and simulation results show that compared to other algorithms which only control loads or parts of HEMS, it can reduce the electricity fee significantly.