Switching two optocouplers based on different voltages
A slightly different way to solve your problem is to use AC and handle the two halves differently, as in the circuit below:







simulate this circuit &ndash; Schematic created using CircuitLab