We develop nonequilibrium theory by using averages in time and space as a generalized way to upscale thermodynamics in nonergodic systems. The approach offers a classical perspective on the energy dynamics in fluctuating systems. The rate of entropy production is shown to be explicitly scale dependent when considered in this context. We show that while any stationary process can be represented as having zero entropy production, second law constraints due to the Clausius theorem are preserved due to the fact that heat and work are related based on conservation of energy. As a demonstration, we consider the energy dynamics for the Carnot cycle and for Maxwell's demon. We then consider nonstationary processes, applying time-and-space averages to characterize nonergodic effects in heterogeneous systems where energy barriers such as compositional gradients are present. We show that the derived theory can be used to understand the origins of anomalous diffusion phenomena in systems where Fick's law applies at small length scales, but not at large length scales. We further characterize fluctuations in capillary-dominated systems, which are nonstationary due to the irreversibility of cooperative events.