How do thermostats work?