OK. That’s what I assumed. I’ll dig into how to do that!. Thanks.
I added the following and it generates a random number with each YAML reload but it does not update after that. When I put the value in the template editor it updates every 30 seconds or so.
- platform: template
sensors:
random_delay_value:
friendly_name: "Random Delay Value"
value_template: "{{ (range(0, 1)|random|int) }}:{{ (range(1, 59)|random|int) }}:00"
What can I do to make it update?
First, the range(m, n) function returns an int value between m & (n - 1), inclusive. So, range(0, 1) will always return 0. If you want a value between m & n, inclusive, you need to use range(m, n + 1).
Next, since you seem to want a random number of minutes, why not just use a single value in minutes?
Lastly, the suggestion was to create a variable, not a template sensor.
How about something like this:
- # Create a random number of minutes between 1 and 120.
variables:
random_delay_value: "{{ range(1, 121)|random }}"
- delay:
minutes: "{{ random_delay_value }}"
- # Notification step goes here
...
Thank you for the clarification.