I can’t think of any way to do that in a template. It might be possible to save the last motion detected time with a bunch of automations, and evaluate that in your template, but if you think about what you are trying to accomplish there is probably a much easier way.
Automation Triggers and Conditions have a built-in “FOR” clause that measures how long a sensor has been in a particular state. So if your goal was for example to turn off a light if there has been no motion for 30 minutes you could do it like this:
- alias: no motion for 30 min
trigger:
- platform: state
entity_id: sensor.template_motion_woonkamer
to: 'off'
for:
minutes: 30
action:
service: light.turn_off
entity_id: group.all_lights