Turn off the breaker switch for the electrical box at the breaker box before installing the motion-sensor switch. Unfasten the screws holding the cover plate over the electrical box with a screwdriver and set the cover plate out of the way.
Unfasten the screws holding the electrical switch onto the electrical box with a screwdriver and pull the switch away from the box so you can access the terminal screws. Loosen the terminal screws with a screwdriver and remove the electrical wires from the terminals, discarding the electrical switch.
Fasten the black wire from inside the electrical box to the black wire of the new motion-sensor switch with a wire connector. Fasten the red wire from the motion-sensor switch to the white wire inside the electrical box with a wire connector.
Cap the end of the yellow wire from the electrical outlet with a wire connector and cap the green wire with another wire connector. Set the wires inside the electrical box and secure the sensor switch to the electrical box with the screws.
Place the cover plate over the sensor switch and secure the plate with screws. Turn the breaker switch to the electrical switch on at the breaker box.