Use a Certain Time trigger in Rule Machine for the beginning of the time period that you want the random time within. Then, use a Delay on the action you want to happen at a random time, putting the total length of the time window as the time, and selecting Random, like this (for 20 minutes window):
If you wanted the random event to be between 10 minutes before and after sunset, the trigger would be for Sunset-10 minutes, the start of the 20 minute period during which you want the randomness to happen.
