I’am trying to create a timer by adding a number input with a slider to ajust the minutes and a button to start the countdown. The number input is typ float and therefore i get 22.0 (e g.) instead of 22. So i have to convert the input to int. This is my approch, which does not work:
The timer works fine when i hardcode the duration. What do i missunderstand?
I am using this approach for my dynamic timer. From the input_number in minutes, convert it to seconds and using the timestamp expression to convert it to the duration time format. See if you can use the same approach to get yours to work.
Fehler beim Aufrufen des Diensts timer/start. offset {% set ctime = states.input_number.timer_minutes.state %} {% set ctime = ctime|float*60 %} {{ ( ctime) | timestamp_custom('%H:%M:%S', false) }} should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F' for dictionary value @ data['duration']
I will do further tests with that code part, if you or someone here around has another hint: any help will be appreciated!
This works. You can set the duration in seconds so you don’t need to format HH:MM:SS. If your input_number represents minutes, you just have to multiply it by 60
I get the exact same error message with your example. It feels like the template is not rendered / intepreted and it hands only the complete string over to the service and not the calculated result…
You cant use templates in the core version of Lovelace.
baunan’s and obaldius’ examples work because they are calling the service with a template in the backend (an automation or script), not the frontend (Lovelace).
You have two options:
Put your service call and template in a script. Call the script from Lovelace. Or
that’s something that has been happening for a long time. The timer works although the remaining time doesn’t update. There are workarounds in the forum if you search, but nothing straightforward afaik.
This one too if you are into Node red. It persists HA restarts, which the other doesn’t, and has a countdown that updates… It’s not difficult to set up, it’s actually very easy
I’am on HKI Framework / Theme to setup the front end. I tested my problems in love lace to prove that it is not related to Homekit infused theme and not to mess up things or to make it even more complicated to analyze whats wrong.
Therefore i’am unsure how to realize that. I will check that out!