Electrical – How to replace this light switch

electricallightingwiring

I want to swap out a light switch with a sensor switch in my boiler room but I'm not sure how to wire it. I took out the old switch expecting to find 3 wires connects: a metal ground, a white return, and a black hot. Instead, all of the White returns are capped together in the box and two black wires are connected to the switch.
original switch

I tried wiring the sensor in the same way and it was on for a while but wouldn't switch off when I pressed the plate under the sensor. Then, it did go off and now won't turn on any more. Here's what the new switch looks like:
— photos deleted because I don't have enough karma to post more than 2 links —

And, this is what the inside of the box looks like:
inside of box

My guess is either the sensor switch is defective or I wired it wrong and it's defective now ;p

Any help in understanding this wiring would be appreciated. The whole house is like this and I want to replace this switch and put a dimmer in the nursery. I've just never seen a setup with what looks like 2 hot wires and no return.

Thanks!

Best Answer

Light wireBasically the only "HOT" is the black coming into the box from the Main. The switch is an interrupt to the light, which uses the electricity. So the way they have it set up is the switch is just passing the Voltage through from black to black when on, and creating an "Open" when it is off. At which point the light (or a plug outlet) would be off; this is where the actual Black/White setup in your mind really matters.