Skip to content

Remove stale siren off-listener handles on retrigger#694

Open
dmulcahey wants to merge 1 commit intodevfrom
pr/fix-siren-stale-off-listener
Open

Remove stale siren off-listener handles on retrigger#694
dmulcahey wants to merge 1 commit intodevfrom
pr/fix-siren-stale-off-listener

Conversation

@dmulcahey
Copy link
Contributor

@dmulcahey dmulcahey commented Feb 27, 2026

This pull request addresses an issue with the siren entity's timed activation logic, specifically preventing the accumulation of stale canceled handles when the siren is repeatedly turned on with a timer. The changes ensure that canceled listeners are properly removed from the entity's internal tracking, preventing unbounded growth and potential resource leaks. A new test is also added to validate this behavior.

Bug fix: Proper cleanup of stale handles on repeated timed activation

  • Updated the async_turn_on method in zha/application/platforms/siren.py to remove canceled listeners from the _tracked_handles set, ensuring that only active handles are tracked and preventing memory/resource leaks.

Testing improvements

  • Added a new test test_siren_repeated_timed_turn_on_leaks_stale_tracked_handles in tests/test_siren.py to verify that repeated timed activations do not retain stale or canceled handles, and that the cleanup logic works as intended.## Summary
    Removes stale canceled timer handles when re-triggering timed siren activation.

Failing tests addressed

  • tests/test_siren.py::test_siren_repeated_timed_turn_on_leaks_stale_tracked_handles

Verification

  • pytest (branch-local targeted run): listed test passes.

@dmulcahey dmulcahey force-pushed the pr/fix-siren-stale-off-listener branch from 09b6537 to 896e40e Compare February 27, 2026 16:04
@dmulcahey dmulcahey changed the base branch from dm/codex-issue-exploration to dev February 27, 2026 16:04
@dmulcahey dmulcahey closed this Feb 27, 2026
@dmulcahey dmulcahey reopened this Feb 27, 2026
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.51%. Comparing base (9d03d63) to head (896e40e).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #694   +/-   ##
=======================================
  Coverage   97.51%   97.51%           
=======================================
  Files          62       62           
  Lines       10949    10952    +3     
=======================================
+ Hits        10677    10680    +3     
  Misses        272      272           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant