Repository navigation
Clamp the siren duration to the Start warning field's range - #1069
zigpy-review-bot wants to merge 1 commit into
Conversation
Warning Duration is a uint16 (ZCL R8 8.4.2.2.1.1), but Home Assistant's `siren.turn_on` accepts any non-negative duration. A duration above 65535 seconds failed to serialize with a ValueError, so the siren never turned on. Clamp it to 65535 seconds, for the command and the entity's off timer.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1069 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 61 61
Lines 10870 10871 +1
=======================================
+ Hits 10597 10598 +1
Misses 273 273 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I don't think someone is going to try to turn on a siren for 18 hours with an automation... |
|
Agreed, it's an edge case: any realistic duration works today, and only a duration above 65535 s (about 18 h) fails, with a If it isn't worth carrying, it can be closed together with #1068 — that's your call. If you'd rather keep it, it now conflicts with #1067 (the same lines in |
Summary
Severity: low (the audit's estimate)
Home Assistant's
siren.turn_onaccepts any non-negative duration, but the Start warning command's Warning Duration is auint16, in seconds (ZCL R8 8.4.2.2.1.1 and 8.4.2.2.1.5). A duration above 65535 seconds made zigpy fail to serialize the command with aValueError, so the siren never turned on. This clamps the duration to 65535 seconds.Changes
zha/application/platforms/siren.py: aMAX_DURATION = 0xFFFFconstant;AdvancedSiren.async_turn_onandBasicSiren.async_turn_onclamp the requested duration to it, for the command and the entity's off timer.tests/test_siren.py:test_siren_duration_above_uint16, for the full and the basic siren, serializing the command for real and checking the sent Warning Duration.Testing
ValueError: Failed to convert warning_duration=86400 …and passes with the fix.tests/test_siren.pyandtests/test_select.pypass; pre-commit (codespell, ruff, mypy) passes on the changed files.Opened by the scheduled code audit; not requested by a maintainer.
Fixes #1068