You could create a binary template sensor that triggers to “on” when the light has been off for ‘x’ minutes, and then “off” when the light is not off. Then in your automation, check the state of this binary sensor, and do the appropriate action.
Hi! I have been trying to do it but I’m not an expert on templates. It’s first time trying that.
I have try with the template editor doing a trigger template but the template editor I think that dos not work with triggers.