Help with my switch automation

Hi so I am using a automation to turn off a switch or light after some time but i want to be able to input said time from a numerical input this is my code

- id: '1572362955848'
  alias: Test automation
  description: Prueba para apagar las luces despues de x tiempo de un numeric input
  trigger:
  - entity_id: switch.test
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - wait_template: 'seconds: "{{ states(''input_number.sala_temp'') }}"'
  - alias: ''
    data: {}
    service: switch.turn_off

It says the automation triggers but it doesnt turn off after desired time

Wait template doesn’t work like that

- id: '1572362955848'
  alias: Test automation
  description: Prueba para apagar las luces despues de x tiempo de un numeric input
  trigger:
    platform: state
    entity_id: switch.test
    from: 'off'
    to: 'on'
    for:
      seconds: "{{ states('input_number.sala_temp') }}"
  action:
    service: switch.turn_off
    entity_id: switch.test
1 Like

i just tried the program you used but it doesnt turn off the switch, but if i turn it off and then on it will instantly turn it off, do you think this might be a bug?

Is the time right in your environment?

yes


I am runing ubuntu server on a VM, as this is my test setup on a PC, but also on my house i am running a RPI4 so i can test on that later tonight

Okay, and have a you deleted the old test automation and restarted homeassistant?

Might need to put |int at the end of the template too, thinking about it.

I used seconds: “{{ states(‘input_number.sala_temp’) }}”|int and it marks it as an error i removed it and now the automation doesnt trigger

i already restarted the whole thing i got this to work with node-red so i whink i am sticking with that for the moment but thank you very much i am still willing to learn more about automations, i think i need to learn yaml or something, anyway do you know a good post about device tracking i am using the app on my android phone and i want to turn on the garage lights when i arrive after sunset thanks again

The int goes on the end of the template itself, but glad you got sorted.