Raycast collision for switches

I would like to know how can I use Physics.Raycast to check for one-time-only collisions.

Now the code works fine, but the only problem is instead of the collision happening only once, it happens as long as the hit is valid.

This resulting to multiple executions of the code, where I want only once.

Cache the colliders in a List?