Wiring – Transformer location

junction-boxtransformerwiring

I've got a very basic question – I have a 120V to 24V transformer https://www.functionaldevices.com/products/building-automation/details/TR40VA040/ and on the transformer surface it calls out "install in metal box only". So my understanding is that it's supposed to be screwed into the metal junction box, but the transformer itself is to be located outside of the box, possibly in the wall cavity, like pictured here:

enter image description here

Is this a correct way of positioning the transformer? Or does "in metal box" mean literally "inside of the metal box"?

Best Answer

That is exactly right.

The purpose of this arrangement is to put the mains voltage on one side of the "Great Wall Of Separation", and the low voltage on the other, as called out by the Code requirements for (not) mixing low voltage and mains.

However, as Tyson points out, the junction box must remain accessible and have a cover. I assume this is unimproved space, or you are putting a box extension on it to raise it to the finished wall surface. Burying the entire junction box and transformer behind drywall, that is no-go.