@jab01701mid I don't actually have to solve it, because I got a sufficiently working solution without any proper gates, just putting a constant strong pulldown of the signal pin to gnd, and letting the optocoupler output act as an even stronger pullup.
But it seems like a proper solution could be made into a tiny PCB you could put inline in the wiring, and I might snipe myself into doing it as a chance to learn some design.