Skip to content

fix: catch PyViCareNotPaidForError in auto-detection and diagnostics#764

Merged
CFenner merged 1 commit into
openviess:masterfrom
lackas:fix-not-paid-for-auto-detect
May 21, 2026
Merged

fix: catch PyViCareNotPaidForError in auto-detection and diagnostics#764
CFenner merged 1 commit into
openviess:masterfrom
lackas:fix-not-paid-for-auto-detect

Conversation

@lackas
Copy link
Copy Markdown
Contributor

@lackas lackas commented May 21, 2026

Closes the integration-setup crash reported in home-assistant/core#167367.

Problem

PR #737 introduced PyViCareNotPaidForError and made the cached service handle it gracefully, but two paths still propagate the exception unhandled:

  1. _isHybridByFeatures() calls fetch_all_features() and catches only KeyError/TypeError/AttributeError/OSError. For GazBoiler and HeatPump devices the hybrid detection runs during asAutoDetectDevice(), so the exception crashes integration setup before any device is created. This matches the stacktrace reported by @drveni on ViCare integration fails with PACKAGE_NOT_PAID_FOR and no entities created home-assistant/core#167367 ending at __handle_not_paid_for.
  2. dump_secure() / get_raw_json() have no exception handling at all, so the diagnostics endpoint crashes for the same users.

Fix

  • _isHybridByFeatures(): catch PyViCareNotPaidForError and fall back to non-hybrid. Downstream feature access still surfaces paid-only features as PyViCareNotSupportedFeatureError through the cached service.
  • dump_secure(): catch PyViCareNotPaidForError and emit a placeholder dump with device.dataUnavailableReason = "PACKAGE_NOT_PAID_FOR" so diagnostics produce a usable file instead of crashing.

Tests

  • test_autoDetect_NotPaidFor_keeps_original: Vitocal auto-detects as HeatPump despite the API raising PyViCareNotPaidForError.
  • test_dump_secure_NotPaidFor_emits_placeholder: diagnostics dump contains the dataUnavailableReason marker and an empty data list.

All 727 tests pass.

Two paths in PyViCareDeviceConfig propagated PyViCareNotPaidForError to
callers, crashing the integration setup for users whose Viessmann
accounts lack the paid feature package:

- _isHybridByFeatures() called fetch_all_features() but only caught
  KeyError/TypeError/AttributeError/OSError. For GazBoiler and HeatPump
  devices the hybrid detection runs during asAutoDetectDevice(), so the
  exception crashed integration setup before any device was created.
  Fall back to non-hybrid (treat as the originally detected device
  type); the cached service still surfaces paid-only features as
  PyViCareNotSupportedFeatureError on demand.

- dump_secure() / get_raw_json() had no exception handling, so the
  diagnostics endpoint crashed for the same users. Emit a placeholder
  dump with the device metadata and a dataUnavailableReason marker.

Fixes the integration-setup crash reported in
home-assistant/core#167367.
Copy link
Copy Markdown
Member

@CFenner CFenner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@CFenner CFenner added the bugfix label May 21, 2026
@CFenner CFenner merged commit 447d647 into openviess:master May 21, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants