91JJ
(91JJ)
1
I use this format to help set up a timer, to then trigger/stop an automation.
I’m currently trying to set after 5 minutes, something happens…
However, I’m trying to make it that, one minute before, something else happens…
(i.e., after 5 minutes a light will turn off, 1 minute before, it’ll flash to warn you)
00:{{ '%0.2d' % states('input_number.bedtime_routine_auto_turn_off_timer') |int
}}:00
Can anyone help edit this to be able to subtract 1 minute or 60 seconds?
1 Like
petro
(Petro)
2
just add - 1
in your template… You’ll need to wrap it in parenthesis so the % gets the whole operation.
1 Like
91JJ
(91JJ)
3
Sorry, I’m being dumb.
I am, but getting this error.
TypeError: %d format: a number is required, not str
petro
(Petro)
4
yes, wrap (states… -1 ) in parenthesis
1 Like
91JJ
(91JJ)
5
Sorry Petro, I’m really not getting it 
petro
(Petro)
6
-1 goes after int, int is included in the parenthesis as is -1
1 Like
91JJ
(91JJ)
7
Got there in the end!
00:{{ '%0.2d' % ((states('input_number.bedtime_routine_auto_turn_off_timer') |int ) -1) }}:00