older ones are often electrical, but not really electronic. they use a bimetal strip that bends due to changing temperatures, to complete a circuit at the point you set the slider. it's actually a really fascinatingly simple bit of tech.
The Mercury is in a glass tube with two wires and the tube is attached to the bimetallic strip in such a way that the motion of the Mercury due to gravity as the strip moves will close the circuit between the two wires. The Mercury is just being used a liquid conductor.