Residential and business buildings account for a large fraction of the overall world energy consumption. Despite the high energy costs and the raising awareness about the impact on climate changes, a significant part of energy consumption in buildings is still due to an improper use of electrical appliances. In this paper we propose GreenBuilding, a sensor-based system for automated power management of electrical appliances in a building. We implemented GreenBuilding as a prototype system and deployed it in a real household scenario to perform a prolonged experimental analysis. The obtained results show that GreenBuilding is able to provide significant energy savings by using appropriate energy conservation strategies tailored to specific appliances.