Skip to content

Reply to IAS ACE keypad requests with the request's TSN - #1041

Draft
zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/ias-ace-responses-carry-request-tsn
Draft

zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/ias-ace-responses-carry-request-tsn

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Summary

Severity: low (the audit's estimate)

When a keypad sends an IAS ACE Arm or Get Panel Status command, ZHA's Arm Response and Get Panel Status Response went out with a newly allocated ZCL transaction sequence number. ZCL R8 §2.4.1.3 requires a frame generated in response to a request to copy the request's TSN, which is how the keypad matches the response to its request. Zigbee2MQTT passes the request's transaction number back for both responses. The effect on real keypads hasn't been confirmed on hardware.

This sends both responses with the TSN of the request.

Changes

  • AlarmControlPanel.cluster_command passes the received TSN to the Arm and Get Panel Status handlers.
  • The arm handlers (_disarm, _arm_day, _arm_night, _arm_away, _handle_arm) return the ArmNotification instead of a ready-made arm_response coroutine, and _cmd_arm sends the arm_response with the TSN. Arming from the consumer (Home Assistant) has no request, so its unsolicited Arm Response keeps a fresh TSN as before.
  • _send_panel_status_response sends the Get Panel Status Response with the TSN.

Testing

  • test_alarm_control_panel_responses_carry_request_tsn sends Arm (TSN 0x42) and Get Panel Status (TSN 0x43) from a frient KEPZB-110 and checks the TSN of ZHA's responses. It fails at dev 2da1a5b (the Arm Response has no tsn) and passes with the fix.
  • Full suite: 1782 passed. pre-commit (codespell, ruff, ruff format, mypy) passed.

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

Fixes #1038

The Arm Response and the Get Panel Status Response were sent with a fresh ZCL transaction sequence number. ZCL R8 2.4.1.3 requires a frame generated in response to a request to copy the request's TSN, which is what a keypad uses to match the response to its request.

Pass the TSN of the received Arm and Get Panel Status commands through to the responses. Arm requests issued from the consumer keep a fresh TSN.
@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 21, 2026
@zigpy-review-bot

Copy link
Copy Markdown
Collaborator Author

The red test jobs come from a flake unrelated to this change: on Python 3.14, tests/test_gateway.py::test_gateway_startup_failure errored at teardown because the cleanup check found a leftover executor thread (asyncio_1, already stopped). The 3.12 and 3.13 jobs were cancelled by fail-fast; they didn't fail. This PR only touches the alarm control panel platform and its test. Re-running the failed jobs should turn CI green.

Verified (5 checks)
  • Full test suite at 15081d8: 1782 passed (local, serial).
  • test_gateway_startup_failure on its own: passed 10 times out of 10.
  • The new test_alarm_control_panel_responses_carry_request_tsn fails with dev's alarm panel source (assert None == 66 on the Arm Response TSN) and passes with this fix.
  • zigpy's _create_request uses the given tsn and allocates a fresh one only for None, so arming from Home Assistant (no request, tsn=None) still sends a new TSN.
  • ZCL R8 §2.4.1.3 says what the description claims, and Zigbee2MQTT sends armRsp and getPanelStatusRsp with the request's transaction number.

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.

IAS ACE Arm Response and Get Panel Status Response don't carry the keypad request's transaction sequence number

1 participant