The hot source is spliced to the black, fan wire and the black wire running to the dimmer. At the other end, the black cable wire is spliced to one of the hot dimmer wires, it doesn’t matter which one. The other dimmer wire is spliced to the red wire in the switch box which is spliced to the blue, light wire at the other end.
Here the exhaust fan is controlled by a timer instead of a switch. There should be two hot wires and a ground coming out of the timer casing, splice one of these to the hot source. Spice the second to the black, cable wire running to the fan. Splice the source neutral to the white cable wire and the ground to the ground wires. At the fan splice the wires, matching the colors of each.
This ground fault circuit interrupter wiring diagram of the same device leaves the switch out of the protected circuit. With this arrangement the receptacle is protected but the switch remains outside the circuit. This arrangement can be used to control a light or other device where the extra protection of a gfci is not necessary.
The black cable wire is connected to the top terminal on the switch and spliced to the black and blue wires at the fan at the other end. The neutral source and ground are spliced through to the white and ground connections at the fan.