how does a digital thermostat work