While I am aware that there are various techniques to add offset randomness relative to time, it seems to me that implementing a native random offset would make time automations significantly more simple.
An example of this enhancement:
automation:
trigger:
platform: time
# Feature requested: random_at. This example is - 30 minutes and +45 minutes relative to 15:32:00.
random_at: '15:32:00'
random_min: '-00:30:00’
random_max: ‘00:45:00’
Thanks for your consideration and please VOTE if you like the idea.
It’s not an easy one to code… the random function must only be called once to set a time, and this has to be done at the earliest possible point, the time then needs to be stored temporarily so it can be checked. Obviously generating a random number every time the test is done will have unintended consequences (the trigger may never fire) - rather like a Monte Carlo simulation. @123 posted the correct template code for my attempt to do this which is fairly concise, though not as readable as the trigger that you request
trigger this before the earliest point in your example - e.g. 15:00, and use a random time from 2 minutes (120 seconds) to 1h17 (4620s), then have a trigger on this lights_off time