The timer start service duration parameter is being removed

I just installed HA 2023.9.0b1 and have run into this message:

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 found where I make use of duration and it happens to be in Node Red:

I have a little fan that blows intermittently to help seedlings get stronger when grown indoors. The on and off delays are configurable from the frontend so the timer is set with a default duration of zero and when I start it I configure it with the number of minutes I need. If I understand the new error message correctly, I can no longer start the timer passing on the duration… so I tried to “change” the trimer and get an error stating I cannot change a timer that isn’t active.

What should I do? How do I have a timer that gets its duration programmatically before starting?

Edit: I did recreate the timer using the UI as stated in the repair note, but did not see any difference in the setup.

I have the same basic setup, a fan in my grow tent to help seedlings grow thicker stems and roots in the “breeze”. I just use automation for it that turns on the fan for a period of time then uses a delay to know when to turn it off. Is there a reason you need to do it in node red?

@CO_4X4 - I exclusively use Node Red if it is at all possible to avoid the other HA options. I find it way more powerful and easier to troubleshoot. I also don’t want to be hunting around for an automation trying to figure out what method I used to create it. And last, even though I have not fully vetted this makes sense, it is somewhat of a dooms day precaution where I am hoping to save most of my automations in the event something were to happen to Home Assistant and I needed to migrate away. It happened with ST… I quit after 7yrs as the direction they took was just no good for me and had to start from scratch.

I did this a while back so there are probably simpler ways of doing this, but it works perfectly… well up until this last change. I just need to understand how we are supposed to create a timer with a configurable value. The node at the very top is where I start the timer and set its duration. The function node just before it converts the configured minutes in the frontend to seconds

Are you able to programmatically set the duration of a timer, and then start it using the method you use? If so, how? Whatever you do in HA should be feasible in NR too… or will soon.

Edit: I believe you mentioned using a delay to do the same and if so, I am doing the same, but I use the timer to show the status of the timer as shown in the snapshot above.

1 Like

You just need to place a timer.change before the timer.start. I haven’t looked into the dev plan, but this reorganization is likely being done to enable voice-intiated/controlled timers down the road.

1 Like

@Didgeridrew - I did but it doesn’t work. I says it can’t change a timer that has not started so I would have to start the timer with some default, and then change it. That is how the delay I use works… it is set to 1 minute and then changes to whatever I want, but with the timer I can’t do that as it would be visible on the frontend. Even if for a fraction of a second you would see the bar go from 1m to 30m and then down from there. So… I need the timer to be configured first, then started.

2 Likes

You are correct, the timer does need to be active for timer.change to function. For now you can use the script that follows in place of the setting the duration with timer.start. Make sure the base duration configuration of the timer is set above the maximum value you will actually use, because timer.change doesn’t allow changing duration to a value higher than the configured value.

alias: Timer New Duration
description: ""
fields:
  duration:
    name: Duration
    description: The amount of time the timer should run for
    example: "minutes: 5"
    required: true
    selector:
      duration: null
  timer:
    name: Timer Entity
    description: The timer entity to target
    example: timer.test
    required: true
    selector:
      entity:
        domain: timer
sequence:
  - service: timer.cancel
    data: {}
    target:
      entity_id: "{{ timer }}"
  - service: timer.start
    data: {}
    target:
      entity_id: "{{ timer }}"
  - delay:
      milliseconds: 100
  - variables:
      dur_sec: >-
        {{ [duration['seconds'], duration['minutes']*60, duration['hours']*3600]
        | sum }}
      timer_sec: >-
        {% set t_list = state_attr(timer, 'duration').split(':') | map('int', 0)
        | list %}  {{ [t_list[-1], t_list[-2] * 60, t_list[-3] * 3600] | sum }}
      diff: |
        {{ (timer_sec - dur_sec) * -1 }}
  - service: timer.change
    data:
      duration:
        seconds: "{{ diff }}"
    target:
      entity_id: "{{ timer }}"
    enabled: true
mode: single
3 Likes

I am facing the same warning, in my blueprint (Perform actions based on a dynamic timer) the code was simply:

- service: timer.start
  data:
    entity_id: !input timer
    duration: "{{ slider_value }}"

Now it is:

- if:
  - condition: state
    entity_id: !input timer
    state: active
  then:
  - service: timer.change
    data:
      # If the timer is already running, remove the remaining time
      duration: '{{slider_value - (as_datetime(state_attr(timer, "finishes_at")) - now()).total_seconds()}}'
    target:
      entity_id: !input timer
  else:
  - service: timer.start
    target:
      entity_id: !input timer
  - service: timer.change
    data:
      # If the timer is not already running, remove the duration
      duration: '{{slider_value - as_timedelta(state_attr(timer, "duration")).total_seconds()}}'
    target:
      entity_id: !input timer

Unfortunately, when the timer is not already running this briefly starts the timer with its default duration; I am quite new to HA, so I hope i’m missing a way to set the duration before the timer starts.

While strictly speaking we shouldn’t be discussing beta versions of HA on the forum, just to note that this change has been reverted in b04, so the deprecation notification will no longer appear.

It seems also that a revised version of the timer.start service with a to all intents and purposes equivalent duration option will eventually make it into HA which should also allow us to keep using the original versions of our scripts.

(But nonetheless many thanks to Didgeridrew for the suggested mitigation for the brief time it was required).

2 Likes

Wow. I’m grateful to you for sharing this information! I was just struggling to figure out how to keep my Google Nest Hub timers displaying on the displays. I will clear that message and revert those changes to wait to see how this shakes out in the future.