Skip to content

Treat NaN analog output number values and infinite limits as unset - #927

Merged
TheJulianJES merged 2 commits into
devfrom
zigpy-bot/analog-output-number-non-value
Oct 9, 2026
Merged

TheJulianJES merged 2 commits into
devfrom
zigpy-bot/analog-output-number-non-value

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Follow-up to #917.

MinPresentValue, MaxPresentValue and PresentValue of the Analog Output cluster are single precision floats (ZCL R8 3.14.3.4.2), and NaN is the non-value of that type (ZCL R8 2.6.2.2, Table 2-11). AnalogOutputNumber passes them through unchanged, so a device that reports NaN for a limit it doesn't define gives Home Assistant a NaN minimum or maximum, and a NaN present value is shown as nan instead of unknown.

Changes:

Tests: test_number_non_finite_range (NaN, inf, -inf at join), test_number_non_finite_max_reported (a NaN maximum reported after joining, through the recompute added in #917) and test_number_nan_present_value fail on dev and pass with the change. The full suite passes.

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.23%. Comparing base (b6eb2c3) to head (584604a).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #927   +/-   ##
=======================================
  Coverage   97.23%   97.23%           
=======================================
  Files          61       61           
  Lines       10666    10669    +3     
=======================================
+ Hits        10371    10374    +3     
  Misses        295      295           

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes and regression tests have no identified blocking issues; tests were inspected but not executed.

0 open findings

What changed in this PR

Extends the Analog Output number fixes from #917 to handle non-finite bounds and NaN values consistently with sensors.

Changes:

  • Fall back to default limits for NaN or infinite bounds.
  • Report NaN present values as unknown while preserving infinity.
  • Add regression tests for initialization, reported limits, and value recovery.
File Description
zha/​application/​platforms/​number/​__init__.py Normalize non-finite bounds and NaN present values.
tests/​test_number.py Cover invalid bounds, late updates, and NaN recovery.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TheJulianJES
TheJulianJES merged commit 61e84f8 into dev Oct 9, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants