Controlling large number of 24VDC lights / switches with Arduino

I see.

What is odd about the schematic you posted is resistor R3, which is drawn between the switch and the 24V supply. Is that the actual arrangement?

3k is a rather low value for this arrangement, 4k7-10k will drive the opto hard enough. I'd go for R3=10k, that's 2.3 mA through the opto's LED. Remove R4, use the internal pull-up on the input pin, and you can easily detect the switch.

Instead of an optocoupler you could connect the switch to a voltage divider: 47k/10k gives you 4.2V at the pin, and the high resistance offers protection against voltage spikes were they to happen.