Siren fails to turn on with a duration above 65535 seconds

Aperta
#1,068 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@zigpy-review-bot ci sta già lavorando.

Dal 24/11/2026.

  • #1069 di @zigpy-review-bot — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
15/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
embedded-iot

Direzione di ricerca

The bug is in async_turn_on in zha/application/platforms/siren.py, in both AdvancedSiren and BasicSiren, where the duration is passed unchanged to start_warning. Start with tests/test_siren.py, run test_siren_duration_above_uint16 to reproduce the ValueError, and check linked PR #1069 first since the work is already under way. Done means the duration is clamped to 65535 in both classes and that test passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bot: code audit
Problem

Severity: low (the audit's estimate)

A ZHA siren doesn't turn on when siren.turn_on is called with a duration above 65535 seconds (about 18 hours), for example 86400 for 24 hours. Home Assistant's siren service accepts any non-negative duration, but the call fails with a ValueError instead of sounding the siren, and the error isn't one ZHA turns into a readable Home Assistant error.

Both the full siren (AdvancedSiren) and the basic siren (BasicSiren) are affected.

Evidence

The Start warning command's Warning Duration field is a uint16 in seconds (ZCL R8 8.4.2.2.1.1 and 8.4.2.2.1.5; zigpy's IasWd defines warning_duration as t.uint16_t). Home Assistant validates the siren duration with cv.positive_int (no upper bound), and ZHA passes it to start_warning unchanged (AdvancedSiren, BasicSiren). zigpy then fails to serialize the request.

Failing test at 2da1a5b5676158ac7b603ce6b9f42641cb90e7a0

A test added to tests/test_siren.py turns the siren on with duration=86400 and lets zigpy serialize the command for real:

zha/application/platforms/siren.py:315: in async_turn_on
E   ValueError: Failed to convert warning_duration=86400 from type <class 'int'> to <class 'zigpy.types.basic.uint16_t'>
zha/application/platforms/siren.py:377: in async_turn_on
E   ValueError: Failed to convert warning_duration=86400 from type <class 'int'> to <class 'zigpy.types.basic.uint16_t'>
FAILED tests/test_siren.py::test_siren_duration_above_uint16[False] - ValueEr...
FAILED tests/test_siren.py::test_siren_duration_above_uint16[True] - ValueErr...
Proposed fix

Clamp the duration to 65535 seconds in both async_turn_on implementations, for the command and for the entity's off timer. Devices cap the warning at their MaxDuration attribute (240 seconds by default) anyway, so a longer request can't sound longer.

Lingua principale
Python
Stelle
96
Fork
84
Merge medio
3g 1h
PR unite (30g)
13

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zigpy/zha

Tutte le issue di zigpy/zha

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.