Look at the comprehensive example. The trick is to only pay attention to the ON commands and ignore the OFF commands from the motion sensor. Every time the ON command is received, schedule/reschedule the Timer for five minutes. Only when there have been no ON commands for five minutes do you turn off the light.