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?
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.