This paper presents an algorithm for optimal management of aggregated power demand of a group of heating, ventilating and air-conditioning (HVAC) units. The algorithm provides an advanced direct load control mechanism for HVACs that leverages the availability of smart thermostats, which are remotely programmable and controllable. The paper provides a theoretical basis and an optimal solution to the problem of cycling a large number of HVAC units while respecting customer-chosen temperature limits for the purpose of maximum load reduction. The problem is presented in a new light by transforming it into a job scheduling problem and is solved using a combination of a novel greedy algorithm and a binary search algorithm. By leveraging widespread availability of smart internet-based (also referred to as IoT-based) thermostats in today’s environment, the proposed approach can be readily applied to residential buildings without additional electrical/IT infrastructure changes.