The closest I’ve come to this is using a random delay after a fixed time_pattern trigger.
Randomising time_pattern doesn’t seem to work, but triggering an automation every 5 hours that delays with a random range of 0 to 4hr 50min achieves a similar result:
Is it possible that, in the first example, the issue with delay’s template is that it does not zero-pad single digits so sometimes it produces strange time formats like this:
The following template produces zero-padded values:
Sorry, do you prefer Taras or 123 ?
That’s very interesting, I’ve spent some time looking over this and I still can’t see what’s going on.
Petros explained adequately why you need to be consistent with quotes (single versus double) and I sort of understand that enclosing in single { } brackets means “this is an embedded command, interpret it as a command” and double {{ }} means “interpret this as a value and display as such”
Not sure how accurate that is as most of my templating (as you have personally seen) is done throwing speculative requests at the JSON interpreter. The above padding technique is a new one on me. Can you recommend a resource to read up on JSON, especially as it relates to implementation for HA.?
Thanks in advance
Mutt
@123 thanks yeah the delay in my first example isn’t great. I tried to account for padding in the delay in my second example though, that should work right? Or do I need to use your different syntax?
Anyway, my last frustration here is you don’t seem to be able to template the time trigger, which would be great if it worked:
trigger:
platform: time
hours: '/{{ (range(6, 9)|random|int) }}'