The variational principle asserts that the shift-invariant Gibbs measures coincide exactly with the minimisers of the entropy density. A new characterisation of the entropy density leads to the variational principle for the loop O(n) model, and for the annealed version of the Ising model in a random percolation environment. For the former, this leads to an existence proof of shift-invariant Gibbs measures, for arbitrary parameters. For the latter, uniqueness of the shift-invariant Gibbs measure is proven in the nonmagnetic phase. This is based on joint work with Martin Tassy (arXiv:1907.05414).