Dying to find this story I read in the lates 70s or 80s. A fighter pilot from a space battle crashes and takes refuge in a Hab or pod meant for emergencies. Unfortunately, every time he moves, the maintenance robot/drone thinks he is a threat and attacks him. He ultimately defeats the robot by shining his flashlight on a panel where the robots computer resides. The robot attacks the movement and disables itself.
Life Hutch by Harlan Ellison
fighter pilot takes refuge in a life hutch. Maintenance robot has malfunctioned so it attacks anything that moves. Pilot is wounded by robot and figures out that if he moves again the robot will kill him. Pilot blinks his flashlight on panel containing robots brain.