Nonequilibrium thermodynamics of energy transformations