Hi, I use home assistant and try convert an input number to time format.
I can convert the number to minutes but I don’t succeed with the time.
I receive unknow to my timer_countdown_hour sensor.
Who can help me to correct my code?
my input_number variable is timer_countdown
- platform: template
sensors:
timer_int:
value_template: "{{ states('input_number.timer_countdown') | int }}"
timer_countdown_min:
value_template: "{{ states('input_number.timer_countdown') | int %60}}"
# what is the correct way to do this operation ?
timer_countdown_hour:
value_template: "{{ states('sensor.timer_int') - states('sensor.timer_countdown_min') / 60 }}"
What are you ultimately trying to do? I ask because your minutes and hours calculations (ignoring the syntax, etc. issues) don’t look right in the first place.
Thanks for your reply,
I want use a countdown timer that the user can choice how many minutes.
take the number and convert it to HH:MM.
I was searching and try multiple way but it’s not working, also I don’t exactly anderstand the syntax how use it
No, you can’t use a template when configuring the timer. Also, BTW, the duration can be in seconds, or in one of many different formats (including HH:MM, HH:MM:SS, etc.)
What you would do is use input_number.timer_countdown when you start the timer using the timer.start service. E.g.:
voluptuous.error.MultipleInvalid: offset {{ states('input_number.irrigation_set_time') | multiply(1) | timestamp_custom('%H:%M:%S',False) }} should be format 'HH:MM' or 'HH:MM:SS' for dictionary value @ data['duration']