Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timer.finished is triggered with the timer state set to active #115087

Closed
ant-car opened this issue Apr 7, 2024 · 4 comments · Fixed by #115151
Closed

timer.finished is triggered with the timer state set to active #115087

ant-car opened this issue Apr 7, 2024 · 4 comments · Fixed by #115151

Comments

@ant-car
Copy link

ant-car commented Apr 7, 2024

The problem

In 2024.4.0 and 2024.4.1 when the timer.finished event is triggered the timer's state is now active instead of idle. it has broken my automations that have different types of triggers. An example is below

What version of Home Assistant Core has the issue?

2024.4.0 and 2024.4.1

What was the last working version of Home Assistant Core?

2024.3.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Timer

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

- 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

Anything in the logs that might be useful for us?

This is the trigger for the run that has the issue

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

This is the trace for the condition from the above yaml. conditions/1 should be true because this run was triggered by the timer.finished event.

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

Additional information

I've also described this here: https://community.home-assistant.io/t/timer-finished-not-working-anymore/713694/7?u=ant-car

@home-assistant
Copy link

home-assistant bot commented Apr 7, 2024

@nmeachen
Copy link

nmeachen commented Apr 7, 2024

This behavior also interferes with the typical workaround for timer.finished not firing for timers that expire while homeassistant is not running. The most publicized workaround is to add a trigger to your automation for homeassistant.start event and condition of entry to the automation being that the timer is in the idle state. Unfortunately, now that unqualified check on the idle state no longer works as it prevents normal entry when timer.finished is fired.

@bdraco
Copy link
Member

bdraco commented Apr 7, 2024

It looks like the code writes the state only after it fires the event

@bdraco
Copy link
Member

bdraco commented Apr 7, 2024

self.async_write_ha_state()

The state isn't set to IDLE until after the event is fired

bdraco added a commit that referenced this issue Apr 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants