What if the person who activated the motion detector is still in the room? Do you still want to slowly turn off the light 30 seconds after it was turned on?
Perhaps what you want is that if no motion is detected for at least 30 seconds, then it slowly turns off the light.
If your light supports it, there’s an option called transition that specifies the amount of time to either increase or decrease a light’s brightness to a desired level.
If your light doesn’t support transition then you will have to use one of the available scripts that have been created to support this effect. There are several available (search for “fader”); here’s one.