Skip to content

Keep the siren off timer when a turn on fails or overlaps - #1067

Merged
puddly merged 1 commit into
devfrom
zigpy-bot/audit/keep-siren-off-timer-on-failed-turn-on
Nov 24, 2026
Merged

puddly merged 1 commit into
devfrom
zigpy-bot/audit/keep-siren-off-timer-on-failed-turn-on

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Summary

Severity: low (the audit's estimate)

A siren's async_turn_on cancelled the previous off timer before sending the Start warning command. When the command failed, the entity stayed on with no timer left to turn it off; when two turn on calls overlapped, the first call's timer was overwritten but still fired, turning the entity off early and cancelling the second call's timer. This moves the cancel to after the command went out.

Changes

  • AdvancedSiren.async_turn_on and BasicSiren.async_turn_on: call _cancel_off_listener() right before scheduling the new off timer, after start_warning returned, instead of at the start.
  • tests/test_siren.py: test_siren_failed_turn_on_keeps_off_timer and test_siren_overlapping_turn_on, each for the full and the basic siren.

Testing

  • The four new test cases fail at 2da1a5b and pass with the fix.
  • tests/test_siren.py and tests/test_select.py pass; pre-commit (codespell, ruff, mypy) passes on the changed files.

Opened by the scheduled code audit; not requested by a maintainer.

Fixes #1066

`async_turn_on` cancelled the previous off timer before sending the
Start warning command. When that command raised, the entity stayed on
with no timer left to turn it off; when two turn on calls overlapped,
the first call's timer was overwritten but still fired, turning the
entity off early and cancelling the second call's timer.

Cancel the old timer only after the command went out.
@zigpy-review-bot zigpy-review-bot added bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bugfix This PR fixes a bug bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) labels Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (2da1a5b) to head (8da045f).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1067   +/-   ##
=======================================
  Coverage   97.48%   97.48%           
=======================================
  Files          61       61           
  Lines       10870    10870           
=======================================
  Hits        10597    10597           
  Misses        273      273           

☔ View full report in Codecov by Harness.
📢 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

bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Siren entity stays on forever when a turn on fails, and turns off early when two turn ons overlap

2 participants