Why doesn't convection break conservation of energy? 
*

*assumption: Warmer gas rises. (under gravity)

*assumption: A volume of gas cannot have uniform temperature, because gas with fully uniform temperature (all molecules having the same speed) has lower entropy than gas with 'somewhat random' temperature distribution (molecules move at different speeds).


Imagine the following setup (cylinder):



*

*grey: insulation

*yellow: gas with very low thermal conductivity

*orange: solid material with high thermal conductivity

*green: thermoelectric generator


I would expect, that over time, by random temperature fluctuations and warm patches moving upward more, it would create a mild temperature gradient, which could be tapped for power (even if tiny).
Why is this wrong? (It must be, for otherwise it would create energy out of nothing...)
(The pressure will be different, but that shouldn't matter: only the temperature.)
(The container can be tiny, or very tall: I feel like the answer might be a bit different for each.)
Thank you for answering.
 A: The [edit] volume [\edit] average energy of the gas is independent of vertical position. This compensates for the gravitational energy that the [edit] volume [\edit] average kinetic energy increases with z. No energy can be extracted.
A: The same process that makes the gradient of temperature inside happens outside. It only depends on difference of atmospheric pressure with altitude. 
In average there is no gradient of temperature in the walls of the material. 
A: In your setup, the whole thing is (thermally?) insulated. The only heat exchange between the system and the outside is through the thermoelectric generator (usually they have low thermal conductivity).
Case 1: The container is small enough that the gravitational force doesn't vary appreciably.
Let's suppose that the outside temperature is fixed in time and equal to $T_\text{amb}$. Then, if one waits long enough for the system to reach steady state, then the trapped gas will eventually reach $T_\text{amb}$. It would become a gas at uniform temperature.
A gas at uniform temperature has its molecules obeying Maxwell speed distribution, so some of them will move slower whilst others will move faster. If gravity doesn't change appreciably through the height of the container, then it should not have an impact on the temperature distribution inside the container. Thus, overall, there is no temperature gradient through the TEG, and so it does not produce energy.
Case 2: What if  the container is high enough so that g, the gravitational force, changes along its height? 
In that case the pressure would drop (exponentially?) as you rise up, and the temperature would increase (in which way I am not sure), the particle density would lower, I am not sure in which exact way (but this is calculable). So there would be a temperature gradient and a pressure one (thus wind). In that case you could build a heat engine between the planet's surface and the upper gas atmosphere. The effect of gravity would be to cool down the planet (never reaching absolute 0).
Keep in mind that since molecules follow Maxwell speed distribution, some molecule will have a speed greater than the escape velocity of the planet, leaving the system forever, at any given (> absolute 0) temperature. So if you wait long enough, there would be no gas left. And your heat engine would only operate a finite amount of time.
To finish up, this doesn't break conservation of energy because you start with a system out of equilibrium that has a particular energy and that produces a temperature gradient that you can exploit until the hot side (temperature of the hot side of your TEG) reaches the cold side one (planet surface temperature). So in the end you have converted part of the thermal energy of the planet into useful work, thanks to your heat engine, while the whole system cools down and the temperature gradient across your heat engine goes to zero.
Edit : I am probably being sloppy. It may not matter that g varies or not (I am not sure). The conclusion still holds though, and maybe it would be fine if I replaced a changing g for a big sized box versus a small sized one. Small/big compared to what exactly? I am not sure, but probably related to the mean free path of the particles.
A: Assuming convection would continue to separate the warmer molecules from the cooler ones, the rate at which heat was removed at the top of the chamber to drive the heat engine (the generator) would be greater than the rate at which is was returned at the bottom. The temperature of the gas in the chamber would drop.  The output from the generator would match the rate at which energy was removed from the gas.  Energy is conserved.  The process would have to stop when the gas reached absolute zero.
