What you’ve described is the actual way to do it. A flashlight is an actor you attach / detach from a socket.
To effortlessly communicate with a wide variaty of unrelated objects (Press E to Use
Flashlight will be quite different than Press E to Use
Car), look into tutorials addressing BP Interface Communication
.