Home Assistant Community

Timer reset/restart

#1

To reset or restart an active timer while it is running … it is necessary to cancel and start the timer. This will result in an unwanted CANCEL event before the timer gets active again.

Can we have a reset/restart functionality for TIMER to reset the clock to the start time keeping the status as active?

#2

This is already possible by triggering the start service again.

Starts or restarts a timer with the provided duration. If no duration is given, it will either restart with its initial value, or continue a paused timer with the remaining duration.

https://www.home-assistant.io/components/timer/

#3

Yes, I have tried this … but the timer always continues with the remaining time… it never does a restart for me

#4

xx_Nexus_xx is right, the timer actually does restart, but the time remaining in the frontend is still the time of the first period (not restarted).
Even though the timer have been successfully restarted, the frontend display the wrong value.

#5

Same experience here. When restarting a running timer, I would expect the timer to display a new countdown in the frontend, but it doesn’t. But in the background it is indeed restarted, only not displayed in the frontend.

#6

Sounds like a bug, submit a PR

#7
#8

It’s also not working with the latest version (0.88.2 atm). But I found a workaround.

Solution is to cancel the timer before (re)starting.

Here’s an example of motion_sensor1 which, after have been triggered,
will turn light1 on for 2 minutes.

configuration.yaml:

timer:
  timer_light1:
    duration: '00:02:00'

automation.yaml:

- id: '0000000000001' 
  alias: Motion Sensor1 Triggered
  trigger:
  - entity_id: binary_sensor.motion_sensor1
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      brightness_pct: 10
      entity_id: light.light_1
    service: light.turn_on
  - data:
      entity_id: timer.timer_light1
    service: timer.cancel
  - data:
      duration: 00:02:00
      entity_id: timer.timer_light1
    service: timer.start
  - data:
      message: (re)started
      name: 'Timer for Light1: '
    service: logbook.log
  initial_state: 'on'

- id: '0000000000002'
  alias: Timer Light1
  trigger:
  - event_data:
      entity_id: timer.timer_light1
    event_type: timer.finished
    platform: event
  condition: []
  action:
  - data:
      entity_id: light.light_1
    service: light.turn_off
  initial_state: 'on'
#9

Like puk1966, I also had to cancel and start the timer to update the duration on an active timer (push time zero into the future) in version 0.92. I consider this a work around since this segments timer’s active state in history graphs rather showing a continuous active state.