Automation template using "For" time

Hi guys,

Is it possible in a value template with if/then one of the conditions to have something like the gui offers in “For” (time)? If yes, how?

This is one of my template triggers for my NS panel.

platform: template
value_template: >-
  {{ states('sensor.ns_panel_last_click_va') != "" and
  states('sensor.ns_panel_last_click_va') != "newtxt"}}
for: "00:00:02"
id: long

I believe you need to be in yaml mode to get for in templates.

But I think this will apply in whole condition. I need only in one condition (example in your scenario: {{ state('sensor.ns_panel_last_click_va') != "" **for 2min** and .state('sensor.ns_panel_last_click_va') != "newtxt"}}

Show us what you need and we can help you.

I have this:

{% if is_state("binary_sensor.bathroom_iaszone_1","on") and is_state("binary_sensor.bathroom_iaszone_2","on") %}
True
{% endif %}

I need the second sensor to be on for 30 sec but always together with if the first sensor is on also so that I have true the condition

Not possible using a single Template Trigger (because the for option applies to the entire Template Trigger, not a portion of it) but can be done this way:

alias: example
trigger:
  - platform: state
    entity_id: binary_sensor.bathroom_iaszone_1
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.bathroom_iaszone_2
    from: 'off'
    to: 'on'
    for:
      seconds: 30
condition:
  - condition: state
    entity_id: binary_sensor.bathroom_iaszone_1
    state: 'on'
  - condition: state
    entity_id: binary_sensor.bathroom_iaszone_2
    state: 'on'
    for:
      seconds: 30
action:
  ... your actions ...