Skip to content

Add SYS.Model SREQ to report the actual chip model - #295

Open
CubeZ2mDeveloper wants to merge 3 commits into
zigpy:devfrom
CubeZ2mDeveloper:dev
Open

CubeZ2mDeveloper wants to merge 3 commits into
zigpy:devfrom
CubeZ2mDeveloper:dev

Conversation

@CubeZ2mDeveloper

Copy link
Copy Markdown

The node model is currently inferred from the stack version and NV struct alignment: every Z-Stack 3.x device becomes a generic "CC2652", and older devices are either a "CC2531" or a "CC2538". This cannot distinguish between chips like the CC2652R, CC2652P, and CC2652RB, and is wrong for coordinators running customized Z-Stack builds on other hardware.

Add a SYS.Model SREQ command (0x40) that returns the chip model as a length-prefixed UTF-8 string, and probe it while loading network info. The command is a firmware extension, not part of TI's documented MT SYS command set, so the probe degrades gracefully: firmware that does not recognize it (stock Z-Stack replies with RPCError.CommandNotRecognized) or does not answer within 5 seconds falls back to the existing inference. Stock firmware is unaffected and incurs no additional startup delay.

The node model is currently inferred from the stack version and NV struct
alignment: every Z-Stack 3.x device becomes a generic "CC2652", and older
devices are either a "CC2531" or a "CC2538". This cannot distinguish
between chips like the CC2652R, CC2652P, and CC2652RB, and is wrong for
coordinators running customized Z-Stack builds on other hardware.

Add a `SYS.Model` SREQ command (0x40) that returns the chip model as a
length-prefixed UTF-8 string, and probe it while loading network info.
The command is a firmware extension, not part of TI's documented MT SYS
command set, so the probe degrades gracefully: firmware that does not
recognize it (stock Z-Stack replies with `RPCError.CommandNotRecognized`)
or does not answer within 5 seconds falls back to the existing inference.
Stock firmware is unaffected and incurs no additional startup delay.
@zigpy-review-bot zigpy-review-bot added the new feature Adds new feature label Nov 16, 2026
Comment thread zigpy_znp/api.py Resolved
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.55%. Comparing base (c91e7a5) to head (43ee804).

Files with missing lines Patch % Lines
zigpy_znp/api.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #295      +/-   ##
==========================================
- Coverage   98.57%   98.55%   -0.03%     
==========================================
  Files          43       43              
  Lines        3582     3589       +7     
==========================================
+ Hits         3531     3537       +6     
- Misses         51       52       +1     

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

@Hedda

Hedda commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Comment thread zigpy_znp/api.py Outdated

try:
model_rsp = (
await self.request(c.SYS.Model.Req(), timeout=5)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't pass timeout for any other commands. If this command doesn't need an override, timeout=5 should be removed.

Comment thread zigpy_znp/api.py
except CommandNotRecognized:
model_rsp = None
if model_rsp:
model = model_rsp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code currently is untested. Can you add a test? See BaseZStack3CC2531 as an example. I think adding a new base class that has the LED command would allow you to simulate behavior both with and without this command to ensure both branches are exercised.

Remove the explicit timeout override so SYS.Model uses the configured
SREQ timeout.

Add a simulated firmware base class with SYS.Model support and test:
- CC2674P10 model reporting
- Fallback when the command is unsupported or returns an empty model
- UTF-8 response decoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Adds new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants