That looks like it should work. You might want to consider another resistor, about 1k, in series with D1 to slow it down to avoid nuisance tripping and a higher voltage, around 33V, transient suppressor diode in parallel with the whole thing to to clamp, brief high voltage spikes.
Now it may seem like I'm being a little picky, but the schematic is drawn backwards. The convention is power in on the left and out on the right. My first thoughts were it won't work, then I realised the power in is from J3. Mirror the top, so J3 is on the left and it will be much clearer.