Electrical fixture replaced now lights dont go on/off

electrical

I installed a new track light to where the old fixture was.I have power to the light track but the on/ off switch does not work anymore and the lights stay on, unless I turn off the circuit breaker. I replaced the switch thinking it was faulty, but did not help. There are 2 cables at the fixture box with a black and white and ground from each cable.
I attached black to black ,white to white, ground to ground wires from track just like it was before.
Any suggestions?
Thanks,

Best Answer

Wires are NOT color coded as well as you think. However, black-white pairs are grouped into cables. That's important. (I'll disregard grounds; all grounds are ground and all go to each other).

One of the black-white pairs in the ceiling is supply power. Black is always hot, white is neutral.

The other black-white pair is a switch loop. When the switch is on, the two wires are shorted to each other. The white is supposed to have a marking on it to indicate that it is not a neutral wire, but that was skipped. This kind of lazy installation is what makes color coding so meaningless.

Disconnect the wires from each other and check which are energized with the power on. Alternately, you can look for the pair whose resistance changes a lot when you throw the switch, but only check resistance with the power off!

The switch-loop white needs to be marked with black tape etc. Code requires we use that one for always-hot. The remaining switch wire (black) will be switched-hot. That goes to the lamp black.

So join the black supply wire and the white-tagged-black switch-loop wire with a wire nut, push it into the back of the box, and never touch it again. These two wires never went to the lamp, and would have been joined just this way, so there was never any reason for you to touch it. I understand the urge to learn electrical by dismantling things, but position information is very important in lazy wiring where nobody marks anything.

If you want to be the opposite of this, I am a huge fan of marking all wires as necessary so their function is clear, and all like colors can simply be joined to each other. In my world, an unmarked white is neutral, an unmarked black is always-hot. Switched-hots are red, unless there's 2 or more in the same box, then blue and yellow. Two yellows in the same cable are the 2 travelers in a 3-way switch circuit. (travelers are interchangeable and there's no need to distinguish them from one another).

The remaining white (from supply) is real neutral to the lamp. The remaining black (from switch) is switched hot to the lamp.