Delay start of dryer and display countdown

Hi!

I want to create a delayed start / countdown timer that can be set from a lovelace card.

I have created an an automation triggered on the Delay change, this updates the Start-timer.

How can I calculate and update the Countdown-timer in the automation?
It shall be the time-delta of:
“current time (now()”, subtracted from “input_datetime.drying_cabinet_start_time”
How do I calculate this and update the timer: “timer.drying_cabinet_countdown”

alias: Drying Cabinet - Set time on delay change
trigger:
  - platform: state
    entity_id: input_number.drying_cabinet_delay
action:
  - service: input_datetime.set_datetime
    data:
      time: >-
        {{ (now()|as_timestamp + (trigger.to_state.state | float) * 60 * 60) |
        timestamp_custom('%H:%M:%S', True) }}
    target:
      entity_id: input_datetime.drying_cabinet_start_time
mode: restart

Thanks for advice and a lesson in time-handling/calculation… :slight_smile:

Ping… :slight_smile: Anyone?

I think you could use something like this:

service: input_datetime.set_datetime
data:
  timestamp: "{{ now() + timedelta(minutes = states('input_number.drying_cabinet_delay'))"
target:
  entity_id: input_datetime.drying_cabinet_start_time

Thanks! It was a bit cleaner so I updated to:

action:
  - service: input_datetime.set_datetime
    data:
      datetime: '{{ now() + timedelta(hours = trigger.to_state.state | float ) }}'
    target:
      entity_id: input_datetime.drying_cabinet_start_time

But the actual question was regarding the timer: “Countdown”:
“How do I calculate this and update the timer: “timer.drying_cabinet_countdown””. I want to update the countdown timer. :smiley:

EDIT: This was what I was looking for, duration can take seconds:

service: timer.start
data:
  duration: "{{ trigger.to_state.state | float * 60 * 60 }}"
target:
  entity_id: timer.drying_cabinet_countdown

Thanks for inspiration!