Relay or optocoupler to switch thermostat wires
The 4N35 CANNOT switch 24 VAC. It is a transistor output rated at a maximum of 70 VDC and 50 mA.


Providing your switch circuit can tolerate the voltage drop you could use a bridge rectifier and then a 4N35.

However it you could use an MOC3020 or similar. This optocoupled Triac could be directly connected to the switch lines.