This paper addresses energy management and security having as basis sensing and monitoring of cyber-physical infrastructure of consumers and prosumers, and their participation in the Local Energy Market (LEM). The vision is to create a layered multi-agent framework that brings a complete view of the cyber-physical system of LEM participants, and provides optimization and control of energy for said participants. The proposed system is separated into a Market layer and a Cyber-Physical layer, each of them providing dierent services. The cyber-physical layer, represented by SMARTERCtrol system, provides Data Monitoring and Optimized Energy Control of individual building resources. The Market layer, represented by LEM Multi-Agent System, provides Negotiation, Forecasting, and Trust Evaluation. Both systems work together to provide and integrate a tool for simulation and control of LEM.