The typical approach is to have a rule that triggers when the motion detector receives and ON. Then create a Timer for a certain period of time (e.g. five minutes). While the Timer is running reschedule it on subsequent motion detector events. When the timer expires set the switch to OFF.