Repository navigation
Treat NaN analog output number values and infinite limits as unset - #927
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟢 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
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #917.
MinPresentValue,MaxPresentValueandPresentValueof 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).AnalogOutputNumberpasses 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 asnaninstead of unknown.Changes:
min_present_value/max_present_valuefalls back to the existing defaults (0 and 1023), the same as a missing one. Fix analog output number losing its range, unit and name on the first read #917 already ignores a non-finiteresolutionthe same way.present_valueis reported asNone, matching howSensortreats NaN as a non-value (Fix NaN values being recognized as non-values #712). An infinite present value is not a non-value, so it is passed through unchanged, as inSensor.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) andtest_number_nan_present_valuefail ondevand pass with the change. The full suite passes.