# Doubt in proof of condition dG<=0

I tried proving the condition dG<=0 where G is Gibb's free energy and instead ended up proving dB<=0 where B is exergy. Can someone please explain what went wrong with my derivation. I have attached the photo of derivation below. Thank you.

Edit 1: I looked up on the net and it said exergy and Gibb's free energy are same at NPT ensemble. I cannot understand how when both the type of energies use different Temperatures in there formula. Can someone also give an explanation for this??

You have assumed constant temperature and pressure conditions for your system. Also it is implied from your derivation that there is no mass transfer or diffusion. This is an NPT ensemble which achieves equilibrium by minimizing Gibbs Free Energy, $$\Delta G=\Delta H-T \Delta S$$ and looks like that is what you derived. Note that thermodynamic potentials are defined such that they minimize the total energy content of the system under various physical conditions (constant N, P & T for this case gives rise to $$\Delta G$$ while $$\Delta$$ H is defined for a system with constant N,P & S).