<human>:  How does a thermostat work?
<bot>: A thermostat is a device which is used to regulate temperature. It typically consists of a switch, which is connected to a sensor that measures the temperature. The thermostat is programmed to either heat or cool the space based on the current temperature of the space. The thermostat will switch the heating or cooling system on or off, depending on the current temperature. When the temperature is too low, the thermostat will switch the heating on; and when the temperature is too high, the thermostat will switch the cooling system on. This helps maintain a comfortable environment within the space.