Trigger.for / set value dependent of some state

Trying to setup an automation with timer triggered by door contact.

type: opened
platform: device
device_id: 0d8975....
entity_id: binary_sensor.mydoorsensor
domain: binary_sensor
for:
  hours: 0
  minutes: 0
  seconds: '{{ states(''sensor.temp'') }}'

If I try to save this, I get an error: malformed data[‘for’][‘seconds’]. I tried different versions (with/out quotes ) but i got no solution. Is there any chance to set a value with a template?
Tom

Yes but not with a Device Trigger; use a State Trigger.

alias: example
trigger:
  - platform: state
    entity_id: binary_sensor.mydoorsensor
    to: 'on'
    for:
      seconds: '{{ states(''sensor.temp'') }}'
1 Like

Thank you very much for your fast answer.
It works, problem solved.
Tom

1 Like

Glad to hear it solved the problem.

Please consider marking my post above 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 refer to guideline 21 in the FAQ.