text: Q:
  
  Replacing Bath Fan Switch with Timer Switch
  
  I want to install a timer switch (it has four wires, red (load), black (hot), white (common), green (ground) to replace one switch in a 2-gang switch box having five incoming cables (see first photo). One switch controls the fan (want to replace with timer), the other switch (3 way) turns on the recessed ceiling lights. I made a diagram and attached pictures.
  Which of the two common pigtails will I tie the switch common wire to?  Also can someone confirm that my black hot wire ties into the black pigtail? And that I create a new pigtail to tie the red source for the switch to the black of cable #5?
  Any help would be appreciated. Thanks
  
  A:
  
  First, let's label these cables:
  Please confirm that this is correct:
  
  Incoming power
  Travelers to 2nd 3-way switch
  Always on - receptacles? lights in other rooms?
  Either incoming power to 3-way switched lights or switched hot to 3-way switched lights
  Fan
  
  Note that if this diagram is correct, the power and neutral for the 3-way switched recessed lights is separate from everything else. That is perfectly fine, but you need to keep it separate.
  Replacing the fan switch
  "Top"/"Bottom"/"Left"/"Right" are to be ignored when it comes to old switch vs. new switch because each manufacturer (and even each model within a manufacturer) does things differently. In your particular case, the new timer/switch has colored wires so that makes it easy:
  
  Black wire on top of old switch is hot. This connects to hot/black on the new switch.
  Black wire on bottom of old switch is switched hot. This wire, black from cable 5, connects to load/red on the new switch.
  White wire on new switch should be connected together with the 3 white wires that you show near cable 5 - connected to 1, 3 and 5.
  Ground/green should be connected together with all other grounds. Typically you will have a bare ground wire coming out of each cable if these are typical NM (aka Romex) cables. If you do not see any bare wires and it is a metal box and the wires are coming through metal conduit (which may be hard to tell unless you have some other part of the wall open) then the ground is the metal conduit. If that's the case, you can connect the timer/switch ground/green wire to the metal box using an appropriate screw.
  
  