I need a way to display a countdown timer inside a card on a page.
I know it can be done via scripts/automations but I need to be able to change the value and start the timer directly from the card (without updating the automation/scripts every single time)
Is it possible?
- platform: template
sensors:
master_bed_time_remaining:
friendly_name: 'Time Remaining'
entity_id:
- input_number.master_bed_blanket_run_time
- sensor.time
- switch.electric_blanket
value_template: >
{% if is_state('switch.electric_blanket', 'on') %}
{{ [ (states('input_number.master_bed_blanket_run_time')|int - (as_timestamp(now()) - as_timestamp(states.switch.electric_blanket.last_changed))/60)|round(0) ,0 ] | max }}
{% else %}
0
{% endif %}
unit_of_measurement: "min"

Thanks, I assume the Max on time is for setting the countdown timer value? What’s the yaml for that one?
That’s this input number:
input_number.master_bed_blanket_run_time
master_bed_blanket_run_time:
name: Max On Time
min: 5
max: 120
step: 5
unit_of_measurement: min
icon: mdi:update
Thanks for that, almost have it, I have it setup just like you do but the remaining time is not updating in my entities list (if I drag the slider above it does actually update, weird)

Here is what I have, maybe you can spot something wrong:
printer_run_time:
name: Printing Time
min: 5
max: 300
step: 5
unit_of_measurement: min
icon: mdi:update
And:
- platform: template
sensors:
print_time_remaining:
friendly_name: 'Time Remaining'
entity_id:
- input_number.printer_run_time
- sensor.time
- switch.smart_plug_mss310_main_channel
value_template: >
{% if is_state('switch.smart_plug_mss310_main_channel', 'on') %}
{{ [ (states('input_number.printer_run_time')|int - (as_timestamp(now()) - as_timestamp(states.switch.smart_plug_mss310_main_channel.last_changed))/60)|round(0) ,0 ] | max }}
{% else %}
0
{% endif %}
unit_of_measurement: "min"
Have you defined sensor.time in your configuration? It’s part of the Time&Date integration.
Yup that was it thanks, it was in unavailable state for some reason, restarted HA and works fine now 
You’re welcome but you should mark tom_I’s post as the Solution. That’s the one that actually provides an answer to your request for a custom timer.
Yeah marked the correct one now 
I was wondering, is it also possible that instead the switch on/off state to reset the timer, to have it reset when the slider is moved?
Sorry for the stupid question (just started with HA this week!)
Where do I put this code? I’ve tried in the configuration.yaml but it doesn’t like it? Am I missing the section to put the - platform:template into - or do I need to install and integration?