Conversation
Glances v4 only adds "time_since_update" (and the rates) to a plugin's stats once a previous sample exists. The first diskio sample after the Glances server starts therefore lacks it, and get_ha_sensor_data() raised KeyError. In Home Assistant this fails the config entry setup for good when Glances and Home Assistant start together (host reboot). Keep the disk with read/write set to None for that sample, like the network sensors, so the entities are still created and get values on the next update. Fixes home-assistant-ecosystem#57 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #57.
Glances v4 only adds
time_since_update(and the*_rate_per_secfields) to a plugin's stats once a previous sample exists:_manage_ratereturns the raw stats whenstat_previous is None. The firstdiskiosample after the Glances server starts therefore lacks the key, andget_ha_sensor_data()raisesKeyError: 'time_since_update'.In Home Assistant,
get_api()does not catch thisKeyErrorduring setup. When the host reboots and Glances and Home Assistant start together, the config entry ends in a setup error and is never retried: every Glances sensor stays unavailable until the integration is reloaded by hand. Seen with Glances 4.5.7, glances_api 0.10.0 and Home Assistant 2026.9.3 (Home Assistant's first call came 6 s after Glances started).Change: when
time_since_updateis missing (or 0), keep the disk withread/writeset toNone, as the network sensors already do for v4. The disk has to stay in the data, because Home Assistant creates the diskio entities from the keys present in the first update. They are unavailable for that single update and get values on the next one.A test covers the first-sample payload (values from a Glances 4.5.7 server). It fails with the
KeyErrorwithout the fix.pytest,ruff checkandmypypass.🤖 Generated with Claude Code