Detecting device/bulb/socket state without using ACS217
Use a NPN optocoupler instead of a LED and a LDR. You'll find it easier to work with since you can treat it as a normal transistor and put it between ground and an input with its pullup enabled.