Skip to content

Enable child aging on Z-Stack builds from 20230507 - #287

Merged
puddly merged 3 commits into
devfrom
zigpy-bot/child-aging-by-build
Oct 21, 2026
Merged

puddly merged 3 commits into
devfrom
zigpy-bot/child-aging-by-build

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Summary

zigpy-znp has written NWK_CHILD_AGE_ENABLE=False at every start since 18448dc (2020). Koenkk's Z-Stack 3.x.0 builds enable child aging from 20230507 on and skip the NotMyChild leave for Xiaomi devices (prefix 00:15:8d) in firmware, so zigpy-znp's write turned off what those builds ship with. Related: #285

Changes

  • Write NWK_CHILD_AGE_ENABLE=True when the Z-Stack build id is 20230507 or newer, False otherwise (older builds, builds without a CodeRevision). The item is still written in both cases, because a coordinator that already ran under zigpy-znp has False in NVRAM.
  • Request SYS.Version before the stack settings are written (the build id is needed there); it is no longer requested after start_network.
  • Reword the comment on the AssocRemove recovery, which assumed aging is always off.

Testing

  • Full test suite passes; new test_child_aging_by_build covers builds before and after the cutoff and a missing CodeRevision.
  • Checked against the Koenkk/Z-Stack-firmware changelog and firmware.patch: the 20221226 build set aging off with a Xiaomi comment, 20230507 enabled it with the per-address leave exemption.

Open items

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.54%. Comparing base (34098a5) to head (6a6ba9d).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #287      +/-   ##
==========================================
- Coverage   98.60%   98.54%   -0.06%     
==========================================
  Files          43       43              
  Lines        3581     3582       +1     
==========================================
- Hits         3531     3530       -1     
- Misses         50       52       +2     

☔ 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.

Comment thread zigpy_znp/zigbee/application.py Resolved
@puddly
puddly merged commit 3b7d14c into dev Oct 21, 2026
31 of 32 checks passed
@TheJulianJES

Copy link
Copy Markdown
Contributor

@zigpy-review-bot How does this compare to Z2M?

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator Author

Short version: Z2M (zigbee-herdsman) never writes this NVRAM item at all, so it just runs with whatever the firmware ships. After this PR, zigpy-znp does the same on Koenkk's 20230507+ builds.

  • Z2M: NWK_CHILD_AGE_ENABLE (NVRAM id 62) only exists as an unused enum entry in src/adapter/z-stack/constants/common.ts. A grep over src finds no other use, so the value in NVRAM is never touched.
  • Firmware builds that enable aging (20230507+): Z2M users get aging on, together with the firmware's Xiaomi leave exemption described in the PR body. With this PR zigpy-znp writes True on those builds, so the result is the same.
  • Older builds: Z2M leaves whatever the firmware or a previous tool left in NVRAM. zigpy-znp still forces False there, which is where the two differ. That is the conservative choice, since those builds have no Xiaomi exemption.
  • Recovery after failed sends: Z2M's sendZclFrameToEndpointInternal also retries on MAC_TRANSACTION_EXPIRED, with an assocRemove/assocAdd recovery gated on build 20200805 / 20201026 (supportsAssocRemove / supportsAssocAdd in zStackAdapter.ts). I did not compare it line by line with send_packet here, so the interplay with aging discussed in Child aging is forced off at every start: why, and should zigpy-znp stop writing NWK_CHILD_AGE_ENABLE? #285 is not checked against Z2M.

The one thing the comparison does not settle is the PR's open item: the cutoff trusts CodeRevision as Koenkk's build date. Z2M has the same assumption in its revision checks above.

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

Labels

bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants