Report load averages of 0 instead of going unavailable - #152
Open
shauneccles wants to merge 1 commit into
Open
Conversation
The load-average sensors' value_fn ended in `... and la[N]) or None`, so a genuine value of 0 (e.g. an idle router's 15-minute average) was treated as falsy and the sensor went unavailable. Return the indexed value directly when the list is well-formed, only falling back to None when the data is missing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shauneccles
added a commit
to shauneccles/ha-glinet4-integration
that referenced
this pull request
Jun 26, 2026
- Load averages of exactly 0 made the sensor go unavailable: the old `... and la[i]` short-circuits on the falsy 0. Use an explicit conditional so a genuine 0.0 is reported (HarvsG#152). - Treat buffer/cache memory as available when computing memory usage, matching how Linux reports free memory, and expose memory_buff_cache / memory_available / memory_used attributes (HarvsG#111). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Open
8 tasks
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.
Problem
The load-average sensors'
value_fnended in… and la[N]) or None. When a load value is genuinely0— e.g. an idle router's load average —and la[N]evaluates to0(falsy), so0 or NonereturnsNoneand the sensor goesunavailableinstead of reporting0. All three load sensors (1m/5m/15m) share this.Fix
Return the indexed value directly when the list is well-formed, falling back to
Noneonly when the data is actually missing/malformed:Validation against real hardware (GL.iNet MT6000, firmware 4.9.0)
Tested in a Home Assistant dev instance connected to a live MT6000, captured at the same condition (an idle router reporting a
0load average).Before (this branch's base,
master) — router's 15-minute load =0:After (with this fix) — router fully idle,
router_get_status()returnedload_average: [0, 0.02, 0]:Deterministic check on the exact failing input:
Pre-existing bug (present unchanged on
master), independent of #150 — raising it on its own as discussed.