We analyze the computational complexity of the problem of optimally managing a storage device connected to a source of renewable energy, the power grid, and a household (or some other form of energy demand) in the presence of uncertainty. We provide a mathematical formulation for the problem as a Markov decision process following other models appearing in the literature, and study the complexity of determining a policy to achieve the maximum profit that can be attained over a finite time horizon, or simply the value of such profit. We show that if the problem is deterministic, i.e. there is no uncertainty on prices, energy production, or demand, the problem can be solved in strongly polynomial time. This is also the case in the stochastic setting if energy can be sold and bought for the same price on the spot market. If the sale and buying price are allowed to be different, the stochastic version of the problem is #P-hard, even if we are only interested in determining whether there exists a policy that achieves positive profit. Furthermore, no constant-factor approximation algorithm is possible in general unless P = NP. However, we provide a Fully Polynomial-Time Approximation Scheme (FPTAS) for the variant of the problem in which energy can only be bought from the grid, which is #P-hard.