Energy storage resources (ESRs) inherent in building structures are a viable, attractive option to improve power system operation by providing demand-side flexibility. This paper proposes a two-stage optimisation framework for price-based demand response of commercial buildings that include variable speed heat pumps (VSHPs). The proposed framework aims at assisting commercial building aggregators to devise a beneficial strategy for exploiting thermal ESRs in response to electricity prices. Specifically, in this paper, the thermal dynamics of VSHPs are modelled in detail using a set of piecewise linear equations for two different methods of room temperature control. The energy consumption and reserve provision of VSHPs, as well as plug-in electric vehicles, are then co-optimised considering the operating conditions of distribution networks (DNs) for the pre- and post-contingency states of wind power generation. Simulation case studies are performed to estimate the effects of building ESRs on the optimal operation of power systems and commercial buildings under various conditions characterised by: (1) temperature control methods, (2) ESR penetration levels, and (3) DN operational constraints. (C) 2017 Elsevier Ltd. All rights reserved.