Today conventional rule-based control strategies dominate the control of energy systems in urban districts. Due to many interactions in urban districts, commissioning local energy systems and defining rules for optimal setpoint control is a challenge. Currently, expert knowledge based on comparable systems serve as basis to set up increasingly complex controls. Moreover, this process is becoming increasingly challenging due to the growing use of technologies such as heat pumps or storage systems to increase the share of renewable energies in the building energy sector. In academia complex systems are often controlled via computationally intensive methods such as model predictive control. Disadvantages are the complex initial commissioning, high computing demands, and a lack of interpretability of the system's behavior. To capture the complex interrelationships, the proposed method extracts simple rules from artificial optimal control. The energy system is first represented by a mathematical optimization model. The model determines the optimal plant operation for given demand time series. The optimization results are fed into white box machine learning models, such as Decision Tree Classifiers, to determine the revalent influencing factors and dependencies that are decisive for the determined operation. The process yields the relevant variables and setpoints for a simplified rulebased control. The extracted rules for an existing energy system are validated against the existing rule set and the theoretical optimum according to the optimization results by simulation. The rules can be interpreted by technical staff and applied to existing programmable logic controllers. This study introduces a toolchain to automate the creation of rule-based controls for complex energy systems.