As far as I can tell, the correct way to use traps for defense in my settlements is to place a trigger (plate or tripwire) where an enemy is likely to walk over it, place a trap nearby the trigger, and wire them to a generator in series. This works, in as far as my Defense rating goes up when I do it.
But, I frequently find that my own settlers, in their random wanderings, are setting the traps off. This seems especially true if I try to place both traps and guard posts at chokepoints -- the guards on patrol walk over the traps. It also makes it impossible to trap high-value areas like the crops, generators, etc.
I assume that I could set the traps, then fence them in so no one could trigger them, and my Defense rating would go up, but it also breaks the immersion a bit, and makes traps useless in a real fight. I may as well just drop nothing but turrets.
Is there some trick to setting the traps so that the bad guys might still fall into them, but the good guys won't?