The three pairs of wires correspond to the three functions. You should be able to find labels or a note in the manual explaining which is which, but for now I'll assume:
- black/white: main light
- red/white: fan
- blue/white: night light
The green wire is a ground wire.
How you wire this up depends on what you have available. A 3-way switch will not help you here; you need multiple switches, and for that to work you may need more wires between your switch box and your fan/light fixture. Most likely, you will have a single cable (with a black, white, and bare ground wire) running to your fan. In that case, you can wire it up as follows:
- bond the bare ground wire with fixture green ground wire
- bond the supply white (neutral) with all fixture whites
- bond the supply black (hot) with the fixture black, red, and blue
That assembly will work, but it's not ideal as your fan, light, and night light will all turn on/off from a single switch.
A better version would be to have two switched wires running up to the fan. You can do this either by adding another 2-conductor cable (such as 14/2WG) running up to the fixture, or you can use a 3-conductor cable (e.g. 14/3WG) where there is a single neutral (white) and two switched hots (black and red). Assuming you have the 3-wire cable, your setup would be:
- bond the bare ground wire with fixture green ground wire
- bond the supply white (neutral) with all fixture whites
- bond the supply black (hot 1) with the fixture black and blue (lights)
- bond the supply red (hot 2) with the fixture red (fan)
This allows you to control the fan and light separately with your two switches, but again has the shortcoming that the nightlight is only powered when the light switch is on. Which probably defeats the purpose!
And that leaves the final, best option: two switched hots as above, plus an unswitched hot power supply wire (let's call it black-unswitched). In this setup, you'll
- bond the bare ground wire with fixture green ground wire
- bond the supply white (neutral) with all fixture whites
- bond the black-unswitched supply with the blue (nightlight)
- bond the supply black (hot 1) with the fixture black (main light)
- bond the supply red (hot 2) with the fixture red (fan)
This setup is ideal because you have switches to control your fan and light separately, and you have constant power to supply the night light. That means your fixture can use the unswitched power to run the nightlight constantly, and when you come in and turn on the main light, the nightlight either turns off or just becomes irrelevant.
As you can see, you have a few reasonable options for how to wire this fixture. Another variation is that you might have unswitched power in the fixture area, and only one cable running to your switch box. If that is the case, you'll be using the cable to the switch to both send power to the switch and receive power back when the switch is on. If you have that sort of set up, you could provide constant power to the nightlight even if you have a single switch controlling the fan and light together. You'll need to make a couple more junctions in/near the fixture in this case, involving the switch.
Note: a 3-way switch will not be helpful. A 3-way switch has three wires (call them A,B,C) and allows you to switch between connecting A+B or A+C. Two 3-way switches can be used together to allow switching a light from two locations. But as long as you have a switch with only two positions, you can only choose between on and off, not off, on-fan, on-light, and on-fan+light. For that you need two switches, or some sort of switch designed to control two separate fixtures.
Final cautionary note: To do this right, you will need some basic electrical knowledge, including how to properly connect wires with wire nuts and how to work on a fixture safely. If you aren't familiar with this sort of electrical work, you should get someone who is (experienced DIYer or pro) to work with you. Improper electrical work has a massive risk of hurting you, either while you're trying to install it or later on when a failure can put you at risk of fire. Good luck and be safe!
Best Answer
The old fan's bracket seems to be identical, so I'd just go ahead and continue the old one in service, rather than exchange an essentially identical piece.
The biggest problem you have is this fan is supplied with single-use stab connectors. Once you stab, you can't un-stab. So you need to get it right the first time, or just cut those stupid things off and use wire-nuts.
Clearly, one pipe is supply, and the other pipe is onward switched fan/light power to something else. Since you're in conduit, the installer had more liberty to choose wire colors, and chose yellow when ordinarily someone would use black or red. Don't worry too much about that. But white is definitely neutral, regardless!
For now, get a plain receptacle. Pick one pipe, and attach the white to neutral and yellow to hot on the receptacle. Plug something in there e.g. a night light. Turn the breaker on, and see if the night light will light up. If it does, you have identified supply.
Turn the power off and try the other pipe - same thing. See if any switch makes that "night light" come on. It's possible power is coming from both directions! Weird, unlikely, but we need to cross it off the list.
OK, so with the receptacle and night light lighting up off the fan/light switch, what now is broken?? I bet something that used to come on with that switch, has stopped doing so. That is where that other pipe goes to.
Anyway, now mount the fan. You most likely need to make a 3-way connection between the fan's white wire and the 2 white wires from the ceiling. That stab connector won't do. You'll need a wire-nut or a Wago lever connector. (or stabs with more slots, but I do not like those, no I don't.)
Then, you'll (probably) need to do the same with the fan's black wire and the 2 yellow wires. Again, use a wire-nut or a lever connector (looks like a stab connector but is locked/released by levers).
That should do it. As far as ground, the conduit is ground. When the fan is re-mounted to the bracket the conduits come in on, the steel case of the fan will be fastened to the bracket, and that will ground the fan. You don't need to do anything with the 2 ground wires. You can leave them in their little stab connector.