Wire 24VAC to 6N135 for input to nodemcu or arduino

I would use a dual LED type like PC814 or LTV814 for AC with a 10 to 68nF ceramic cap from output transistor collector to emitter (GND) to filter ripple. Make the LED current 3 to 6mA RMS.