Sustainable energy is the goal in this era, but one of the resources that is more abundant and reliable than light or water is gravity itself. It is common in classical mechanics to measure how much gravitational potential energy an object has.
Gravity per se never provides energy. Energy can be generated via gravity only when the elevation of the center of mass of a system can decrease. As mentioned by Robert J. Low, hydroelectric power is the most common example. There have been some other examples, such as creating downdrafts via evaporating water at a high elevation in dry air. The air chilled by evaporation is denser than the surrounding air and yields energy upon falling. Rising hot air, for example in chimneys or via release of heat of condensation if the environmental lapse rate exceeds the moist adiabatic, also represents a yield of gravitational potential energy --- the center of mass of the atmosphere falls as denser surrounding air takes the place formerly occupied at low altitudes by the rising warm air. In some cases the immediate source of wind energy is a loss of gravitational potential energy of the air --- strong winds behind cold fronts result largely by the cold air mass sliding underneath the warmer one, lowering the center of mass of the entire system.
Hydroelectric power is, of course, gravity, but it also requires heat, so that rain brings the water that produced the power back to its original position.
Power generated by tides, in my opinion, is closer to the spirit of the question: there only gravity is used. Of course, eventually the source of energy (the fact that the Earth and the Moon do not rotate in sync) will disappear, since there can be no truly perpetual motion machine: but in the medium term, so to speak, this has no importance.
@Giorgio Fontana: the main problem with your suggestion is not merely that it is unrealistic: it is further formulated in such a way that it would presumably be hard to be sure, once we had made such an engine, that it actually corresponded to what was ``predicted''. In other words, it is not so much sci-fi, as a pseudo-science version of Nostradamus. The latter has, we are told, predicted everything that happened up to now, but in such a way that it was impossible to notice the prediction before the event. Similarly, I venture to predict that the ``recipe'' you give will never be used in order actually to construct a workable device.