Consistent formulation for thermomechanical contact based on microscopic interface laws