Like so many inventions, the thermometer evolved over an extended time and through the works of many individuals. Galileo and other European scientists of the 16th and 17th centuries for example, understood that air expanded and contracted. Galileo is often credited with inventing the thermometer, but what he actually developed was a Thermoscope because it did not have a scale. The thermoscope measured the hotness or coldness of air based on the principle that air is a gas and it expands and contracts. In so doing, it pushes the fluid within a sealed tube up or down and this correlates with the temperature of the air.
The Galilean thermoscope above is an example of the closed tube environment that contains air (gas) and water (liquid). Musée des Arts et Métiers thermoscope de galilée 1592 | Wikimedia