Repository navigation
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>
|
Adding some field evidence from a production install, because the impact of Environment: Home Assistant 2026.10.0b0, Glances 4.4.1 on the monitored host Reproduction: Reboot the monitored host. Glances restarts fresh, and its Why this is severe: During config-entry setup this is not a The disk.get() fallback with None rates in this PR matches exactly what a Happy to test a branch or wheel against our setup. |
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