  Optimally combining frequency control with self-consumption can increase
revenues from battery storage systems installed behind-the-meter. This work
presents an optimized control strategy that allows a battery to be used
simultaneously for self-consumption and primary frequency control. Therein, it
addresses two stochastic problems: the delivery of primary frequency control
with a battery and the use of the battery for self-consumption. We propose a
linear recharging policy to regulate the state of charge of the battery while
providing primary frequency control. Formulating this as a chance-constrained
problem, we can ensure that the risk of battery constraint violations stays
below a predefined probability. We use robust optimization as a safe
approximation to the chance-constraints, which allows to make the risk of
constraint violation arbitrarily low, while keeping the problem tractable and
offering maximum reserve capacity. Simulations with real frequency measurements
prove the effectiveness of the designed recharging strategy. We adopt a
rule-based policy for self-consumption, which is optimized using stochastic
programming. This policy allows to reserve more energy and power of the battery
on moments when expected consumption or production is higher, while using other
moments for recharging from primary frequency control. We show that optimally
combining the two services increases value from batteries significantly.
