Input number for automation, error

Hi, I would like to add the chance to change a default timing set for an automation, creating a slicer on lovelace. I’ve seen that is possible using the input_number. I’ve tried with the following configuration but I’m getting this error:

Invalid config for [automation]: expected float for dictionary value @ data['for']['hours']. Got None expected float for dictionary value @ data['for']['minutes']. Got None.

configuration.yaml

input_number:
  hours:
    name: ore
    icon: mdi:clock-start
    initial: 1
    min: 0
    max: 3
    step: 1
  minutes:
    name: minuti
    icon: mdi:clock-start
    initial: 15
    min: 0
    max: 60
    step: 5

automations.yaml

- id: '1670488106467'
  alias: Termocoperta_1ora
  description: Spengo la termocoperta dopo 1 ora dall'accensione
  trigger:
  - platform: device
    type: turned_on
    device_id: 84a0f117d9dfe632aa10123865117f47
    entity_id: switch.termocoperta
    domain: switch
    for:
      hours: "{{ states('input_number.hours') | int(0) }}"
      minutes: "{{ states('input_number.minutes') | int(0) }}"
      seconds: 0
  condition: []
  action:
  - type: turn_off
    device_id: 84a0f117d9dfe632aa10123865117f47
    entity_id: switch.termocoperta
    domain: switch
  mode: single

What should I do in order to fix it?

Thanks!
Marco

I’ve fixed adjusting the automation as follow:

- id: '1670488106467'
  alias: Termocoperta_1ora
  description: Spengo la termocoperta dopo 1 ora dall'accensione
  trigger:
  - platform: state
    entity_id: switch.termocoperta
    to: 'on'
    for:
      hours: "{{ states('input_number.hours') | int }}"
      minutes: "{{ states('input_number.minutes') | int }}"
  condition: []
  action:
  - type: turn_off
    device_id: 84a0f117d9dfe632aa10123865117f47
    entity_id: switch.termocoperta
    domain: switch
  mode: single

Now I’ve to found an alternative solution that guarantee me to change the running timer when the device has already been activated. Because with this structure using a ‘for’ I haven’t any leverage on timing once it has been turned on.

As you have found, device triggers do not support templates. There are other reasons for avoiding device triggers, conditions and actions: