I got around to mounting the switch for the hatch work lights. Basically the plan here was to have it so that whenever the hatch was closed, the work light circuit would be interrupted so that the lights could never come on if the hatch was closed. This is separate (kinda) from the cargo lights in the back, which I want to be able to turn on and off at will. But since the work lights are tied into the cargo light switch, I needed a way to interrupt the circuit to the work lights separately.
More specifically, I wanted the work lights setup so that you would have to explicitly toggle a manual switch to turn them on, so that they would not always be on whenever the hatch was open (this would unnecessarily drain the battery, especially if I go halogen bulbs). However I also wanted an automatic switch that would kill the lights whenever the hatch was closed, even if the manual switch was left on. So basically this is a safety off switch.
One way to do this would be to use a jamb switch of some kind, but I couldn't find anywhere convenient to mount one. Later on I remembered that I had bought a magnetic reed switch when I was messing with the doorless stuff as a possible replacement for the door jamb switches, so I decided to try using that. Here is a pic of the switch in question. I believe it is item #65985K14 on McMaster-Carr, which is where I bought it, but I'm not 100% on that. It's a $20 switch so that and other details are right. Basically it's a switch with three wires (see below), a magnet, and four nuts that can be used to mount the two pieces.
The switch has separate wires for constant (white), normally-open (red), and normally-closed (black). Pass a magnet in front of the tip of the switch, and red goes closed and black goes open. Move the magnet away and the switch goes back to default. I decided to use the black wire, so that a magnet on the hatch would cause the circuit to stay open, and opening the hatch would move the magnet and the black wire would go closed. This was used to drive a coil circuit on a relay, which interrupted the ground wire to the work lights.
The only part of the hatch that comes inside the jeep is at the very bottom, where the hatch panel meets the scuff panel. There was not enough room under the scuff panel to easily mount the switch so I put it at the bottom of the D-pillar instead. Since this is where all the hatch wiring is terminated in the cabin anyway it made setting up the relay easy too. This pic shows the switch and relay mounted.
Although the tip of the switch can be mounted
almost flush, experimentation showed that the tip needed to come through the panel in order for everything to work reliably. For one thing, the plastic panels down there really interfere with the magnetism. For another, I did not like the idea of the panel banging against the tip of the switch all the time. So I drilled a little hole for the switch tip to stick through and got a rubber grommet to provide some flexibility for the panel and shock insulation for the switch.
The last part was to mount the magnet. Unfortunately I have not been able to finish this yet due to a couple of problems. However I have temporarily mounted the magnet that came with the switch with some tape, as seen here
Although the hatch does come inside at the bottom, it does not come in very far, so the magnet has to stick out the front of the hatch patch in order to pass in front of the switch tip. What I need to do is get a strong magnet that will drive the switch when it gets close to the tip. This works with the magnet in my nut-and-bolt holder, and I have found some small magnets at True Value that appear to be strong enough. Unfortunately I broke my Dremel and so I have not mounted the magnets yet.
With everything put together, it all works as expected. When the hatch is closed, the magnet activates the switch, which prevents the coil circuit on the relay from activating, which in turn prevents the ground circuit on the work lights from activating. When the hatch is open, the magnetic switch reverts to its default position, which closes the coil circuit on the relay, which in turn closes the ground circuit on the work lights. If the manual switch on the cargo lamp is in the right position, current will then flow to the work lights.