During the last years, renewable energy sources and their management have become increasingly important to help driving forward the energy transition and slow down the global warming. Current energy management systems are either simple but not optimal or very complex, computationally intensive and optimal. Despite that, they also often focus on the optimization of just the electrical energy flows of buildings so far. This work focuses on the development of a linear model predictive controller as well as heuristic energy flow controllers for optimizing a complex thermally-electrically coupled system. For that, a real world building is modelled in MATLAB Simulink and used for the training process of the heuristic controllers as well as for the evaluation of the different optimizers in simulation with different timespans. It is found that the linear MPC works better than a rule-based self consumption optimization and that the heuristic controllers work significantly better than these two for all evaluation timespans up to 180 days, while they perform significantly worse for 364 days.