Template trigger with 'for:'-setting seems only to work with constants not with variables

I created a little simple blueprint to show what i mean:

  name: 'Test Template Trigger for:'
  description: 'Test if for option accepts variables'
  domain: automation
      name: Duration
        hours: 0
        minutes: 0
        seconds: 15
          enable_day: false

  tv_duration: !input duration
  tvd_seconds: "{{tv_duration.seconds}}"
  tvd_minutes: "{{tv_duration.minutes}}"
  tvd_hours: "{{tv_duration.hours}}"

  v_duration: !input duration
  vd_seconds: "{{v_duration.seconds}}"
  vd_minutes: "{{v_duration.minutes}}"
  vd_hours: "{{v_duration.hours}}"

  - platform: template
    id: diff
    # every 5 minutes: 43,48,53,58,3,8,...
    value_template: >
      {{now().minute % 5 > 2}} 
      hours: 0
      minutes: 0
      seconds: 15

#  Error when using: 'seconds: "{{vd_seconds}}" ' or 'seconds: "{{tvd_seconds}}" '
# Template variable warning: 'vd_seconds' is undefined when rendering '{{vd_seconds}}'

  - service: notify.persistent_notification
    metadata: {}
      message: >
        Tijd: {{now()}} {{"\n"}}
        minute: {{now().minute}} {{"\n"}}
        tv_duration: {{tv_duration}} {{"\n"}}
        tvd_seconds: {{tvd_seconds}} {{"\n"}}
        tvd_minutes: {{tvd_minutes}} {{"\n"}}
        tvd_hours: {{tvd_hours}} {{"\n"}}
        v_duration: {{v_duration}} {{"\n"}}
        vd_seconds: {{vd_seconds}} {{"\n"}}
        vd_minutes: {{vd_minutes}} {{"\n"}}
        vd_hours: {{vd_hours}} {{"\n"}}

mode: single

Goal here is to check whether the trigger reason last for a defined time. This time has to be a blueprint input, but I tried everything, created trigger_variables and normal variables to put into the ‘for:’ setting, nothing works, only constants.

When running the blueprint as uploaded here, all works OK. but when changing one of the for-arguments into a row with a variable:

seconds: "{{vd_seconds}}"

… a error is thrown :

Template variable warning: 'vd_seconds' is undefined when rendering '{{vd_seconds}}'  ') 

… in the system-logs.

Running/testing the automation manually (so without the trigger) runs OK, showing that all variables exists.

What am I doing / is going wrong here? Or is using a variable in this ‘for:’ setting just not possible?

First off, if you are generating trigger_variables, you do not need to regenerate them as variables. Trigger_variables are just variables that are available for the trigger, but they are available for the scope of the automation as well.

Also you are not using any of the trigger_variables you generated in the actual trigger, so delete them. You are way over complicating this…

Then to actually troubleshoot this, look at the trace and find out what those variables are generating as.

Other info:
From the docs

The output of this selector is a mapping of the time values
the user selected. For example:

days: 1 # Only when enable_day was set to true
hours: 12
minutes: 30
seconds: 15

So look at this to pull the data out as individual data points, or just paste in the !input and it will use it and you don’t have to break it out at all…
Here’s how I use duration in a trigger.https://github.com/SirGoodenough/HA_Blueprints/blob/c05d6fb431c1d84cb145c7d6dd5ffe5a60b1d9e2/Automations/Device_tracker_Monitor_and_Notifier.yaml#L273.

Map values for an input_select? - #5 by petro.

@Sir_Goodenough Thank you for your reply !!

Did all of that, all the variables exists here for me to make it easy to switch while testing.
In the end HA does not seem to accept any variable in the 'for: ’ sections of a template trigger. I tried also

seconds: "{{tvd_seconds}}" 

this gave the same error (only the variable-name differs in the error)

So I assume that using variables in the for:-part of a template-trigger is not possible.
Or can any-one show me a working example?

You may have missed that in my example as I was still editing it.

@Sir_Goodenough Yes I am fast :wink:
I see your example, trying it at this moment …

It works with

for: !input duration

Thank you very much !!

Please consider marking my post with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to [guideline 21 in the FAQ]{How to help us help you - or How to ask a good question}.