An energy management system (EMS) connects all energy-relevant components of a building — photovoltaic system, battery storage, heat pump, charging station and household appliances — into a coordinated overall system. The aim is to prioritise self-generated solar power, minimise grid feed-in and grid consumption, and reduce operating costs. The EMS collects real-time data via energy meters and communication protocols such as Modbus, SunSpec or KNX, and dynamically adapts control based on weather forecast data and variable electricity tariffs. In smart home environments, the EMS forms the central intelligence that connects all trades and responds to user behaviour and external grid signals.