An Architecture for Energy Management in Smart Appliances