Free energy is a generalization of energy when the system exchanges heat with the environment. Energy, in its turn, can be extracted from lagrangian under the symmetry of time $(\frac{\partial L}{\partial t}=0)$. However, I can't find any sources that links the free energy directly from lagrangian. Is there any way to do that? If it is, what symmetry is it based on?