Maxperson
Morkus from Orkus
Wouldn't you be casting it before you are in a position such that the trap can hit you? Like if the mechanism is inside a chest, you are probably searching for traps before you even open it.
If it's triggered by opening the lid, then the lid is part of the trigger. I can't think of a trap where the trigger or at least part of the trigger would not be within line of sight. Even if the trap cannot hit you, it's still a trap and would qualify under the criteria given. It would still "inflict a sudden or unexpected effect you consider harmful or undesirable, which was specifically intended as such by its creator.". It doesn't say at the end, "and can hit you.".