Help with automation: switch off after x minutes (minutes > 60)

Hello,

for my battery loading, i added a slider where i con choose after which number of minutes it should turn the loader off (set a switch to off).
Currently i have configured my slider for the minutes to be from 30 to 480 with a step of 10.

I don’t know how i can add this to my automation to set a switch to off again after this is over?

Thanks for your help!
/ Ralf

Many possibilities, you could start an automation when it’s switched on and add a delay based on the slider to switch it off. Something like this:

- delay:
    minutes: {{ states.input_number.whateveryoucalledyourslider.state | int }}

Another possibility:

trigger:
  platform: state
  entity_id: switch.myswitch
  to: 'on'
  for:
    minutes: "{{ states('input_number.xxx')|int }}"
action:
  service: switch.turn_off
  entity_id: switch.myswitch

This will turn the switch off after it is turned on and stays on for the number of minutes defined in the input_number slider. This will better handle the case where the switch is turned on, but for less than the period defined, but is then turned back on and then stays on for the defined period.

Thanks for both ideas. I thought i have to convert into hours if i have more than 59 minutes…

/ Ralf