In blueprints it would be useful to have a possibility to define templated values for “time_pattern” components.
Consider this faulty automation:
description: ""
mode: single
trigger:
- platform: time_pattern
minutes: >-
{{ "/1" }}
condition: []
action:
- service: notify.persistent_notification
data:
message: xxx
Use case: using helpers to define a time_pattern.
petro
(Petro)
December 22, 2023, 11:18am
2
You can do this with template triggers.
trigger_variables:
entity_id: !input some_entity_selector
trigger:
- platform: template
value_template: "{{ now().minute % states(entity_id) | int }}"
1 Like
Thank you, this is what I do now (not exactly this code, a similar one).
Just wanted to propose some more flexibility…
{{ (now().timestamp()|int(default=0) % (MINUTES|int * 60) == 0) }}
petro
(Petro)
December 22, 2023, 11:24am
4
Yeah, this method won’t work for seconds. But then again, even if we add templates to seconds, it still won’t work for seconds because there’s nothing in templates that automatically creates a per-second resolution.
yes, and time_pattern trigger seems to support seconds (never tested myself).