Turn off light after 10 minutes of no activity

I found this automation script: https://www.home-assistant.io/cookbook/turn_on_light_for_10_minutes_when_motion_detected/

Which basically does what it says. But I was wondering if it were possible to have it only turn the light off after 10 minutes, if it was off initially?

Try to use state last changed;