We consider mechanisms to optimize electricity consumption both within a home and across multiple homes in a neighborhood. The homes are assumed to use energy management controllers (EMCs) to control the operation of some of their appliances. EMCs, which are a feature of the emerging SmartGrid, use both prices and user preferences to control power usage across the home. We first present a simple optimization model for determining the timing of appliance operation to take advantage of lower electricity rates during off-peak periods. We then demonstrate, using simulation, that the resulting solution may in fact be more peaky than the ``non-scheduled'' solution, thereby negating some of the benefits (for the utility) of off-peak pricing models. We then propose a distributed scheduling mechanism to reduce peak demand within a neighborhood of homes. The mechanism provides homes a guaranteed base level of power and allows them to compete for additional power to meet their needs. Finally, we introduce a more powerful EMC optimization model, based on dynamic programming, which, unlike our first optimization model, accounts for the potential for electricity capacity constraints.