The development of energy management systems that optimize the electrical energy flows of residential buildings has become important nowadays. The optimization is formulated as a symbolic regression problem that is solved by genetic programming, which provides near optimal results while being highly performant during application. Additionally, the so-trained energy flow controllers are explainable and therefore address three of the current major disadvantages of most existing solutions. 260 controllers are trained to calculate the optimal gridfeed-in value for an inverter and are evaluated for their ability to minimize the energy costs and to support grid stability and battery lifetime. Additionally, they are compared to two existing energy management systems, a rule-based self consumption optimization and a linear model predictive controller. It is shown that this energy management system can significantly minimize energy costs compared to both reference systems by up to 58.25%, support grid stability and prolong battery lifetime by up to 76.48%.