This paper presents a method for the energy management of a set of smart homes, in which batteries, thermal storage and demand response are considered as flexibilities in order to achieve minimum operation costs. To cope with the uncertainty of load forecast, a two-stage stochastic optimization process is proposed, in which the first stage decision is the committed energy to be purchased, and t...