Distributed monitoring for energy consumption optimization in smart buildings