I'm installing a new ceiling fan. I have 2 black and 2 white wires coming from the ceiling. 1 black wire is not a power source. The 2 white wires are capped together. I've left the non power black wire source capped and left the 2 white wires capped together. After hooking up everything the fan and light works. Yay!! However, there is a wall switch that should turn on and off the fan and it's not working. I'm assuming it has something to do with the non ground black wire. If so, how do I connect it to the fan switch? Thank you for your time.
What was pre-existing in that box was a switch loop, however, it was botched rather badly... if it were hooked up that way, the switch would switch neutral, which is wrong.
Wires enter a box in cables. This implies a wire grouping, and the grouping is important. For instance your box has 2 cables that each look like this.
(Yours probably doesn't have the red wire).
The cable with the "live" black is supply/always-hot. It has a partner "white wire" which is supply/neutral. (which, to belabor the point, is in the same cable as the black.
The dead cable is switch loop, and its white wire should be tagged with black electrical tape because it will be used as an always-hot wire. This tag should be done on both ends, but at least do it here.
Now join the two always-hots (black and remarked white) and push those wires into the back of the box.
What remains is a black from the switch loop and a white from supply. Hook this up exactly as you'd expect.
White is used for always-hot to make it more obvious it's been re-tasked as a hot. If white were the switched-hot, it would appear cold with the switch off (while black would appear hot) and people would mistake it for neutral. Also, re-marked white wires are required to be re-marked to indicate they are hots. This is the only remarking allowed in electrical, and only in cables.