Can I set a timer duration in a script (no timer.start)

Hi,

I know I could set a duration with data if i start a timer with service timer.start but could I set a new duration to a special timer without start the timer?

Steffen

timer.start is the only service call that allows you to set a timer’s duration. If you can use it to set a new duration for an active timer, the timer will restart using the new duration.

OK thanks, so I could not define from user choose before starting the timer or must use a input entity.

Steffen

Did you find a solution for this?
I would like to have an easily configurable timer duration on my dashboard.

Only a workaround using helper to save the duration and in automation I use the helper to set the timer duration.

Thanks for the response, I am using something similar:

alias: Scentsy Time to Timer
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.scentsy_time
condition: []
action:
  - if:
      - condition: device
        type: is_on
        device_id: befba499e0d934ad7a8f4902dd8c4e09
        entity_id: switch.scentsy
        domain: switch
    then:
      - service: timer.start
        data:
          duration: "{{ states('input_number.scentsy_time') | int }}:00:00"
        target:
          entity_id: timer.scentsy_timer
    else:
      - service: timer.start
        data:
          duration: "{{ states('input_number.scentsy_time') | int }}:00:00"
        target:
          entity_id: timer.scentsy_timer
      - service: timer.cancel
        data: {}
        target:
          entity_id: timer.scentsy_timer
mode: single

Just got this repair notification in my HA instance:

## The timer start service duration parameter is being removed

The timer service timer.start optional duration parameter is being removed and use of it has been detected. To change the duration please create a new timer.

Please remove the use of the duration parameter in the timer.start service in your automations and scripts and select submit to close this issue.

I hope this is not true, as passing different durations when starting the timer is useful in all sorts of situations. For instance, I use it in various security countdowns depending on who is present.

1 Like

The Spook Custom Integration adds a timer.set_duration service that you might find useful…

service: timer.set_duration
data:
  entity_id: timer.my_timer
  duration: "00:15:00"
1 Like