Thermostat with gasket