I tried to implement a random offset in my automation using the template syntax. Based on the 4th delay sytnax example here https://home-assistant.io/getting-started/scripts/#delay and on the Jinja2 documentation, one solution should be:
offset: '+00:{{ range(10,59) | random }}:00'
But that’s not working. chech_config says:
16-11-29 21:13:34 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: offset 00:{{ r
ange(10,59) | random }}:00 should be format 'HH:MM' or 'HH:MM:SS' for dictionary value @ data['trigger'][0]['offse
t']. Got None.
How can this be implemented without validation errors?
I don’t believe that offset supports templates in the way that delay does.
One work-around I’ve seen is in the “creating an alarm clock” thread. It’s a bit of a kludge, but they trigger every minute (platform:time, minutes: ‘/1’) and handle the randomness in their condition. You’d likely also need a condition that makes sure that the action hasn’t already happened (like if you’re turning on a light, a condition that checks to make sure the light it off).