Timer.finished not working anymore

I think since 2024.4.0 my automations don’t trigger on timer.finished.

The automation works otherwise, but the trigger is not. Nothing in the logs.

Is that a known issue? I am on 2024.4.1 now.

alias: test
description: ""
trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.timer_1
  - platform: homeassistant
    event: start
condition:
  - condition: state
    entity_id: timer.timer_1
    state: idle
action:
  - service: fan.turn_off
    data: {}
    target:
      entity_id: fan.1
mode: single

Just checked my logs but I have no such trouble for both 2024.4.0 and 2024.4.1 so that is weird. Are you sure that is it?

I do not understand your timer idle condition though. Why would you check for whatever state you thiink the timer has after a timer finishes? You already know it just finised. If you think it might have started again you would most likely not catch it here anyway.

1 Like

Not sure but I didn’t change anything else.

The check is for home assistant startup, in case the timer finished while restarting.

Did you check the trace?

There’s a check in a timer if it should restore on startup or not. If you don’t want running timers to survive a restart just uncheck it?

If I remove the condition it works. Weird that it worked for over a year now.

I guess restoring the timer should work. Thanks for pointing that out.

1 Like

Btw. I do have other conditions like that, that work.

This issue also appeared for me in 2024.4.0 across all automations that are triggered by timer.finished. The automations work fine when i revert back to 2024.3.3.

From what I can tell, when the timer.finished event is fired, the timer’s state is still active.

Automation:

- id: '1648808546330'
  alias: Toilet Timer End
  description: ''
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.toilet
  - platform: state
    entity_id:
    - binary_sensor.toilet
    to: 'off'
    from: 'on'
    for:
      hours: 0
      minutes: 0
      seconds: 10
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.toilet
      state: 'off'
    - condition: state
      entity_id: timer.toilet
      state: idle
  action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.toilet
  mode: single

Trigger:

platform: event
event_type: timer.finished
event_data:
  entity_id: timer.toilet

Condition Trace:

Executed: April 7, 2024 at 7:23:58 PM
Result:

result: false

conditions/0
Executed: April 7, 2024 at 7:23:58 PM
Result:

result: true

conditions/0/entity_id/0
Executed: April 7, 2024 at 7:23:58 PM
Result:

result: true
state: 'off'
wanted_state: 'off'

conditions/1
Executed: April 7, 2024 at 7:23:58 PM
Result:

result: false

conditions/1/entity_id/0
Executed: April 7, 2024 at 7:23:58 PM
Result:

result: false
state: active
wanted_state: idle

conditions/1 should be true because it was triggered by the timer.finished event

I’ve raised a bug here: timer.finished is triggered with the timer state set to active · Issue #115087 · home-assistant/core · GitHub

1 Like

The purpose of the idle check was to deal with the scenario where a restore mode timer might expire while homeassistant is not running. As the timer.finished event does not fire on restart the automation is launched by the homeassistant.start event. The timer state is reset to idle during startup before the homeassistant.start event if the timer expired.

Looks like the original behavior will be restored in 2024.4.2.

1 Like

I confirm it works again.

Important: The timer state needs to be checked at startup - otherwise it won’t trigger. I guess it restores the timer after startup but doesn’t trigger if the timer finishes while HA is offline.