This for a 300TDi with EDC, might also apply to other models.
Symptoms - Air con works intermittently, will work from cold until engine warms a little then it cuts out and wont work again until engine is cold thats after several hours when the coolant is cold.
I checked th refrigerant charge - fine
Checked the dual pressure switch - fine
Checked the evaporator temperature switch - fine
Checked all the wiring - fine
Turned out to be the diode which is located up near where the clutch pedal would be. Yellow/black and purple/black wires going into a clear plastic tube. If you get a wire on the yellow/black wire and earth it, compressor cuts in and air-con works. The diode had broken, replace with any recitifer diode, I used a big massive 6A2 type which is rated at 300 volts, now the air con works perfectly but it has taken me 3 days to diagnose the fault.