Ubiquitous and Pervasive Computing for Real-Time Energy Management and Saving