In the attic I have electricity running out to a junction box. The wire in the junction box connects 2 things. The first one is that it brings power down to a light switch. There's a NM cable coming back up to the attic over the the light.
However recently I added a transformer to the junction box to power up my Ring Doorbell (white to white, green to green, and black to black). I didn't notice this until today that my Ring Doorbell doesn't actually get direct power unless I flip the switch to the light.
I want to ask if I could just add another junction box next to the one I already have so that I would have a dedicated box supplying power to my transformer and doorbell.
So here's what I imagine. First the line power would come to junction box 1. In junction box 1, I would attach the transformer for the doorbell. I would also have another NM cable to bring electricity to junction 2. In junction 2, that's where I would reconnect to the NM cable that goes down to the light switch.
I don't know if this will work. Or is there another way where I can keep the first arrangement and be able to tap power directly from the junction box without the light switch controlling my transformer.