This study presents convex modeling of drainage pumps so that real-time control systems can be implemented to minimize their energy use. A convex model is built based on pump curves and then used in mixed-integer optimization to allow pumps to be turned on or off. It is implemented as an extension to the open source software package RTC-Tools. The formulation is such that the continuous relaxations of the mixed-integer problem are convex, hence branch-and-bound techniques may be used to find a global optimum. The formulation can be used for variable-speed and constant-speed pumps. There are several possible applications, such as optimization of polder systems, pumped-storage systems, or certain water distribution networks. Finally, an example of the drainage pump is presented to compare the method to current methods and show that energy can be saved by using the proposed method.