I've got an automation that keeps a light on if a sensor detects motion, however the odd time I turn it on manually with Alexa it will stay on permanently due to no sensor activity.
What would be the best way to have a timer on this for say 30 mins then if no sensor activity and 30 mins past it would turn it off.
For general 'auto off' needs, there is a great auto-off app here.
I use it for lights/plugs I turn on manually but want to have turn off after a set period of time - like our whole house fan, and a hot water pump that heats up water for the master bedroom:
You may also wish to consider the Switch Timer with reset driver. This will setup a virtual switch which lasts a certain length of time. Check the status of this switch when you want an action to occur.