PV installations in buildings can utilize different on-site flexibility resources to balance mismatch in electricity production and demand. This paper studies cost-optimal and rule-based control for buildings with PV, employing a heat pump, thermal and electrical storage and shiftable loads as flexibility sources to increase the value of PV for the prosumer. The cost-optimal control minimizes variable electricity cost employing market data on electricity price and optionally constrains grid feed-in to zero; the rule-based control aims at maximizing PV self-consumption. The flexibility strategies are combined into a simulation model to analyze different system configurations over a full year. The applicability of the new model is demonstrated with a case study with empirical data from a real low-energy house in Southern Finland. Compared to inflexible reference control with a constant price for bought electricity, cost-optimal control employing hourly market price of electricity achieved 13–25% savings in the yearly electricity bill. Moreover, 8–88% decrease in electricity fed into the grid was obtained. The exact values depend on PV capacity and the flexibility options chosen. Limiting grid feed-in to zero led to less energy efficient control. The most effective flexibility measures in this case turned out to be thermal storage with a heat pump and a battery, whereas shiftable appliances showed only a marginal effect.