Automation based on a variable time pattern

Hello all,

I was wondering, is it possible to have an automation based on a variable time pattern trigger?
I have tried:

trigger:
  - platform: time_pattern
    minutes: /{{states('input_number.my_input_number')|int(2)}}

But it gives me the following error when trying to save:

Message malformed: invalid time_pattern value for dictionary value @ data[‘minutes’]

I know it’s a stretch, as I might not to change the pattern of that automation that often, but I am on a path to improve customization of my configuration.

Thanks

No that option does not support templates (and if it did your single line template is not quoted).

You could use a template trigger

trigger:
  - platform: template 
    value_template: "{{ now().minutes % states('input_number.my_input_number')|int(2) == 0 }}"

This divides the current minutes by your input number and checks to see if the remainder is zero. If it is the trigger fires. % is the modular arithmetic operator.

3 Likes

Thanks! That did the trick with

now().minute

without the ‘s’

2 Likes

Doh. Good catch.