  Motivated by the fact that the (inverse) temperature might be a function of
the energy levels in the Planck distribution
$n_\epsilon=\frac1{\zeta^{-1}e^{\beta(\epsilon)\epsilon}-1}$ for the occupation
number $n_\epsilon$ of the level $\epsilon$, we show that it can be naturally
achieved by imposing the constraint concerning the conservation of a weighted
sum $\sum_{\epsilon}f(\epsilon)\epsilon n_\epsilon$, with a fixed positive
weight function $f$, of the contributions of the single energy levels
occupation in the Microcanonical Ensemble scheme, obtaining
$\beta(\epsilon)\propto f(\epsilon)$. This immediately addresses the
possibility that also a weighted sum $\sum_{\epsilon}g(\epsilon)n_\epsilon$ of
the particles occupation number is conserved, having as a consequence that the
chemical potential might be a function of the energy levels of the system as
well. This scheme leads to a thermodynamics of open systems in the following
way: the equilibrium is reached when the entropy function is maximised under
the constraints that some weighed sums of occupation of the energy levels and
the occupation numbers are conserved.
  The standard case of isolated systems corresponds to the weight functions
being trivial (i.e. $f, g$ are identically 1). For such open systems, new and
unexpected phenomena which might happen in nature can appear, like the Bose
Einstein Condensation in excited levels. The ideas outlined in the present
paper may provide a new approach for the treatment of the irreversible
thermodynamics.
