and i want to be able to use two different input_number to change the 0 and the 13 that are the range of the random … anyone have some suggestion?
Thanks
The time_pattern trigger doesn’t accept a template, but you could do it with a template trigger if you include sensor.time (or even sensor.date_time) in your configuration.
This takes the last two digits of sensor.time's state (which is minutes) and converts it to an integer, then takes the state of the input_number and converts it to an integer, then does modulo math to determine if the minute of the current time is a multiple of the input_number.
For the random delay, first you can simplify what you have to:
- delay: "{{ range(0, 13) | random | multiply(60) | int }}"
or:
- delay:
minutes: "{{ range(0, 13) | random | int }}"
To add in the input_number's:
- delay:
minutes: >
{% set mn = states('input_number.minimum')|int %}
{% set mx = states('input_number.maximum')|int %}
{{ range(mn, mx+1) | random | int }}
Of course change input_number.xyz to the entity_id of your input number entity.
Try to get it to be re-evaluated as the time changes (e.g., put the cursor at the end and type a space, then backspace, then space, then backspace, … – each time you type and then wait the template should be re-evaluated.) Do you see the last template changing from False to True?
I hadn’t actually tried my suggestion, but I just did. In order for it to work the input_number must be at least 2. The reason is that after the first time the template trigger fires, it won’t fire again unless the template first renders False and then back to True. Because sensor.time only updates once a minute, if the input_number is set to 1, the template will always render True, and hence cannot trigger more than once.
Here’s an alternative idea (that doesn’t require sensor.time):
This is a really old topic. I’d suggest starting a new topic specific to your situation. Feel free to tag me. But do include your current YAML code, and explain what you’re trying to do, and why you think it’s not working the way you want.