Box with thread or two 4x4 mm magnets.
Be careful with electricity !!! It would probably be appropriate to use silicone, but I don't have it at the moment.
When modeling, I used the switch model from the link.
https://www.thingiverse.com/thing:3223834
Body_M.stl | 2.1MB | |
Body_T.stl | 2.6MB | |
Bottom_M.stl | 303.0KB | |
Bottom_T.stl | 665.3KB |