How does a coffee perculator know when to stop... Is it timer...Is heat sensor?

Most percolators use a bi-metal spring sensor** to detect when bubbling is no longer occurring. When boiling, steam enters the narrow vertical tube located at the center of the stem, and condenses on the top creating a droplet. The water droplet weighs the spring down far enough to open the electrical switch. This opens the circuit and stops the heating process. Most of the droplets vaporize on contact with the hot metal plate, but others may drip into the perked coffee.