Skip to content

Bug: GraphQLError from UPS query crashes entire coordinator update (all sensors unavailable) #58

@jokerigno

Description

@jokerigno

Bug description

When Unraid is configured with NUT (Network UPS Tools) instead of apcupsd, the upsDevices GraphQL query returns a GraphQLError:

Failed to get UPS data: No UPS data returned from apcaccess

This error is not caught by the _update_ups() exception handler, which only catches UnraidApiError. The uncaught GraphQLError propagates out of the Python TaskGroup in _async_update_data, which cancels all sibling tasks (metrics, disks, shares, docker) and raises UpdateFailed for the entire coordinator. Result: all 200+ sensors become unavailable.

Root cause

In coordinator.py, _update_ups() only catches UnraidApiError:

# coordinator.py ~line 247
except UnraidApiError as exc:
    _LOGGER.debug("UPS Update: %s", str(exc), exc_info=True)

But query_ups() raises GraphQLError when the Unraid API returns an error response (which it does for any non-apcupsd UPS setup). GraphQLError is not a subclass of UnraidApiError, so it escapes the handler and propagates through the TaskGroup.

Fix

Extend the exception handler to also catch GraphQLError and GraphQLMultiError:

except (UnraidApiError, GraphQLError, GraphQLMultiError) as exc:
    _LOGGER.debug("UPS Update: %s", str(exc), exc_info=True)

Both classes are already imported in coordinator.py (lines 27–28), so no new imports are needed.

Environment

  • Unraid: 7.2.4
  • Unraid API version: 4.34.0
  • Integration version: 1.5.1
  • UPS driver: blazer_usb (Megatec/Q1 protocol) via NUT-DW plugin
  • UPS model: Tecnoware ERA PLUS 1500

Feature request: NUT support

The apcaccess backend used by upsDevices is incompatible with NUT-based setups. NUT is widely used for non-APC UPS devices (blazer_usb, usbhid-ups, etc.).

Two paths to consider:

  1. In this integration: add an alternative polling path that reads UPS data directly from the NUT daemon (port 3493, already exposed on 0.0.0.0 by default) using a NUT client library (e.g. python-nut2). This would surface ups.status, battery.charge, battery.runtime, etc. as sensors even when apcupsd is not in use.

  2. In the Unraid API plugin: expose NUT data through the same upsDevices GraphQL query when NUT is the active UPS backend (auto-detect or config option).

Note: HA already has a built-in Network UPS Tools (NUT) integration that connects directly to the NUT daemon — so as a workaround users can configure that alongside this integration.

Workaround

Until fixed, users with NUT-based UPS can apply this one-line patch to restore all non-UPS sensors:

sed -i 's/except UnraidApiError as exc:/except (UnraidApiError, GraphQLError, GraphQLMultiError) as exc:/' \
  /config/custom_components/unraid_api/coordinator.py

Then restart Home Assistant.


Issue reported by a user — fix verified in production on Unraid 7.2.4 / API 4.34.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions