A thermostat is operable from battery, common-wire (“C-wire”), or furnace relay power. The thermostat includes a power source selector, such as a jumper wire, that is set when the thermostat is installed in a heating system. In a gas millivolt heating system, the thermostat operates off of battery power. In heating systems having a C-wire, a diode bridge converter converts alternating-current voltage to direct-current voltage to provide operating power to the thermostat. In heating systems without a C-wire and having sufficient furnace relay current, a triac converter in series with the furnace relay provides voltage spikes to the diode bridge converter to provide operating power to the thermostat when the furnace is on, and the diode bridge converts AC to DC voltage when the furnace is not on. The thermostat can also be used in cooling systems and heating, ventilation, and air-conditioning systems. Thus, the thermostat can be used in a wide variety of applications.