A thermostat works by using a bimetallic strip or thermistor to sense the temperature of the surrounding environment. When the temperature reaches the set point, the thermostat opens or closes the valve to control the flow of fluid to maintain the desired temperature.