We propose a settlement mechanism for optimally scheduling real time electricity consumption which is suitable for an automated demand response control system. Our proposed settlement mechanism, supply function bidding, is interpreted as a Newton algorithm for optimization problems with decomposable structure, and it is shown to satisfy the second fundamental theorem of welfare economics for the case of affine supply function bids. We simulate the behavior of our proposed control mechanism for the case of demand response via room temperature control, and we demonstrate how a suboptimal control policy can have adverse impacts both in terms of system performance but also in terms of economic incentives.