Timer.Change Limit?

Hi everyone-
Thanks for taking a minute to read my post. I’m setting up my house fan in HA and ran into a weird limitation and wondering if it’s me, or intended this way. And perhaps a simple work-around.

Here’s the goal:
Starting the house fan automatically starts a 1-hour timer, then turns off when the timer expires. This part is easy enough. There are times though that I want to run the fan longer than an hour, which I thought I could use the Timer.Change service to increase the time by 30 minutes. Using a few taps of a dashboard button, I could then extend the timer to whatever duration I want.

And that’s where I’m stuck. It seems that the Timer.Change service will only add time if the total duration doesn’t exceed the original set time (in my example, 1-hour). I could obviously set the starting timer longer, but with wife and kids, that could leave the fan running non-stop!

Happy to provide more details if needed, but don’t want to get any more wordy than I already have. Thanks!!!

I have the same problem setting the temperature of a boiler. Have you been able to solve the problem in any way?

That’s correct.

I tested it by using Developer Tools > Services. I used timer.change to add 10 minutes to an active 4-minute timer. A message popped up briefly (and it was also recorded in the Log) indicating it cannot extend the duration beyond the timer’s configured duration.

Instead of timer.change you’ll need to use timer.start and set duration to the desired new value. Add 30 minutes to the timer’s remaining time which is not the remaining attribute (which doesn’t count down while the timer is active) but the difference between finishes_at and now().


EDIT

This should help you get started:

  - variables:
      t: timer.your_timer
  - condition: "{{ is_state(t, 'active') }}"
  - service: timer.start
    target:
      entity_id: '{{ t }}'
    data:
      duration: >
        {{ (state_attr(t, 'finishes_at') | as_datetime - now()
          + timedelta(minutes=30)).total_seconds() | round(0) }}
1 Like

I solved the problem by creating an automation that calculates the remaining time of the timer, adds x seconds (900 in my case) and restarts the timer with the new calculated time

action:
  - if:
      - condition: state
        entity_id: timer.countdown_caldaia
        state: active
    then:
      - service: timer.start
        data:
          duration: >-
            {% set tempo = state_attr('timer.countdown_caldaia',
            'finishes_at')%} {{ 0 if tempo == none else (tempo | as_datetime -
            now()).total_seconds() | int(0) +
            states('input_number.extractionfan_runtime') | int(0) + 900 }}
        target:
          entity_id: timer.countdown_caldaia
    else:
      - service: timer.start
        data:
          duration: "00:15:00"
        target:
          entity_id: timer.countdown_caldaia
1 Like

Thanks guys. I haven’t made the changes yet, but planned on something similar. I’m okay with a work-around, just seemed silly to arbitrarily block increases to the timer length and thought posting my situation might get some extra eye’s on it.

Thanks all and appreciate the responses!!!

If you wish, you can create a Feature Request for allowing timer.change to exceed the timer’s original duration.

Good idea and thanks for the reminder.

Here’s a link for anyone who’d like to vote: Allow timer.change to exceed timer’s original duration

1 Like

I found a different work around, perhaps it is also useful for others:

if:
  - condition: state
    entity_id: timer.hal_verlichting_timer
    state: idle
then:
  - service: timer.start
    data:
      duration: "+3000"
    target:
      entity_id: timer.hal_verlichting_timer
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 300
  - service: timer.change
    data:
      duration: "-2700"
    target:
      entity_id: timer.hal_verlichting_timer
else:
  - service: timer.change
    data:
      duration: "+300"
    target:
      entity_id: timer.hal_verlichting_timer

seems to work reliably so far…

1 Like

more upvotes please Allow timer.change to exceed timer’s original duration

Genius, thanks a lot for the inspiration. It enables me to define a cap and nicely get there in incremental steps.
I have added this as an automation to a tap event on a dashboard and the entity shows the new timer value immediately. Me like a lot.