Dynamic "for seconds" trigger with entity

Hi I am currently tinkering around and wanted to try something out.
For various testing purposes I tried to set a “dynamic” for-trigger

See Code below:

description: test
mode: single
trigger:
  - platform: device
    type: changed_states
    device_id: 123
    entity_id: 456
    domain: light
    for:
      hours: 0
      minutes: 0
      seconds: |
        {{ states('counter.counter_bad') | float }}
condition: []
action:
  - action: telegram_bot.send_message
    metadata: {}
    data:
      message: |
        test
alias: variablelight test

I always get a

Message malformed: expected float for dictionary value @ data[‘for’][‘seconds’]

Errormessage.
I tried {{ states(‘counter.counter_bad’) | int }} and I searched the forum and noone changed the “for” value and I really could not find a simple approach for my goal I wanted to reach.

Therefore my questions:
Is this even possible and if yes: what am I doing wrong?

My main goal was to make my light be on longer every increment value x whenever it has been triggered.

And if the light was not retriggered by the current counter value it would simply reset the counter.

Does anyone have Ideas what my issue could have been?
Thanks in advance!

You can template the for field in specific cases, a device trigger does not allow templates in the for field.

1 Like

Oh darn.
Thanks for the fast reply! Then I am going to find another solution for this… thanks!

A normal state trigger should do the trick. You may need to template the entire field.

1 Like

This is what I was afraid.
BUT your Idea brought another Idea in me up that could maybe work without templating and having a monkey-brain that barely understands templating :slight_smile:

Thanks!