I'd seen some steampunk style desk lamps made using pipe with water valves as the switch, and wanted to do something similar for a set of lighted bookshelves made with pipe. Desk lamps using valves as switches are a dime a dozen on Etsy, but finding a source with a good explanation of what components were used to build them was difficult. A good one I found was this one, but the switch only looks like a valve and wasn't made using a real valve. However, that instructable pointed me to some really compact rotary on/off switches and that was the key to me getting mine made. Total cost for my project was a little over $15, but I've since discovered I could have done it for a few dollars less.
[Update: See this Instructable for how I've used the switch. Lighted Pipe Supported Shelves]
Step 1: Parts and Tools list:
For my water valve light switch I used a Mueller Industries, Proline 1/2" shut off valve (105-003NL) and a Carling Technologies R-135-BL rotary switch. I found the switch at Grainger.com and picked it up at a local facility near me for $6.25. I later saw that Lowes has a very similar switch that appears to be the same size for just over $3. This switch can handle 3 amps at 120V or 5 amps at 12V. It cycles through on/off in a clockwise direction each quarter turn. The water valve was a stocked item at a local Ace Hardware for about $9 but Lowes has them too. As I write this, I can't find either on the Lowes website, but I know they are a typically stocked item. Don't get a gate valve. You need the kind pictured in the cutaway where the water enters, goes through a vertical hole and out the other side. The fit is very snug in the 1/2" valve. If you don't mind using a 3/4" valve, it will all fit much easier, but might need some epoxy holding everything in place.
This switch fits inside this valve almost perfectly. Test other brands to see if they fit together as well.
Step 2: Remove Handle
Most valves have a screw at the center of the handle you can remove to be able to remove the handle from the stem. This particular valve has a small nut. Turn the handle to raise the valve to full open before removing it. A later step will be easier if the valve is in the open position. Whichever is the case with the valve you use, remove whatever is holding the handle on and set the handle pieces aside.
Step 3: Remove the packing nut and washer
With a small adjustable wrench, remove the packing nut from the valve body and slide the washer off the stem and set them aside. You'll need the packing nut later, but not the washer.
Step 4: Remove the bonnet nut (difficult)
Remove the bonnet from the valve body. It will likely be extremely tight, so you probably won't be able to simply hold the valve body in one hand and turn the wrench with the other. I had a vice available that I used to hold the valve body while I applied a wrench to the bonnet and got it free. It's possible that threading a length of pipe into the valve might give enough leverage to do it without a vice.
Step 5: Remove the valve washer
A screw holds a washer onto the bottom of the valve stem and will need to be removed for the switch to fit inside. You won't be reusing the screw and washer for this 1/2" valve, but they might be useful if you are using a 3/4" valve or some other brand.
Step 6: Drill out stem threads from inside bonnet nut
The stem will thread out of the bonnet nut at this point, but the stem needs to spin freely and not raise and lower once the switch is placed inside. Either the threads inside the bonnet nut have to be drilled out or the threads on the stem need to be ground off. I chose to drill out the threads using a drill press. [Update: Commenter jhonsvick reports that the brass is soft enough that he had success by simply gripping the stem with pliers and twisting for a few minutes to grind the threads off.] With gloves and safety glasses, I simply held the bonnet nut firmly with a wrench and ran the drill press at a slower speed so I didn't hurt myself if it got away from me, I was able to start with small bits and work my way up to a 1/2" bit, drilling out the threads. Do as much as is needed for the stem to spin freely inside the bonnet nut. In my case, a Dremel with a brass brush smoothed out the burrs nicely to help the stem spin smoothly without any catches.
Step 7: Insert the switch
Thread the wires through the hole in the valve seat and out the side of the valve. Using JBWeld or other high quality adhesive, carefully center the knob on the bottom of the stem and glue them together. Hint: Use a dab of hot glue first to get it positioned just right. It's easier to break it free, clean it off and start over, than the JB Weld would be. Then use the JB Weld around the perimeter. Let the glue or epoxy harden before proceeding.
One person contacted me asking about how to do this if the position of the valve required the wiring to pass through it. I suggested drilling a hole through the partition that divides left from right (you can see it in the cutaway image), and he confirmed that he was able to make that work.
Step 8: Reassembly
With the switch and stem in place, thread the bonnet nut on far enough to hold, but not so far that it starts to bind on the knob. You want the stem/knob to turn easily. Go ahead and attach the handle onto the stem at this point and hold the wires in place so the whole switch isn't trying to rotate inside the valve.
Drip hot glue or use your screwdriver to spread some epoxy inside the valve where the wires come out to prevent the knob from spinning inside the valve and causing the wires to twist. Be careful to not put so much in, or tip the valve, so that anything gets into the upper valve area. If you use epoxy, let it dry overnight.
Attention: If you ever want to be able to disassemble the valve, omit the epoxy or glue on the wire side of the switch. You'll need something there to prevent the switch from spinning, but maybe something like plumbers putty pressed firmly into place would work and still be removable later. There's also the possibility of using the locking nut that came with the switch, but attempting to get it threaded onto the switch threads deep inside that hole would require more patience and a steadier hand than I possess.
Step 9: Finished
After the epoxy has dried, loosen the bonnet nut, apply some loctite to it's threads and retighten it to it's final position where the handle turns smoothly with a click, click, click, at each quarter turn.