fix: catch PyViCareNotPaidForError in auto-detection and diagnostics#764
Merged
Merged
Conversation
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.
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.
Closes the integration-setup crash reported in home-assistant/core#167367.
Problem
PR #737 introduced
PyViCareNotPaidForErrorand made the cached service handle it gracefully, but two paths still propagate the exception unhandled:_isHybridByFeatures()callsfetch_all_features()and catches onlyKeyError/TypeError/AttributeError/OSError. For GazBoiler and HeatPump devices the hybrid detection runs duringasAutoDetectDevice(), 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.dump_secure()/get_raw_json()have no exception handling at all, so the diagnostics endpoint crashes for the same users.Fix
_isHybridByFeatures(): catchPyViCareNotPaidForErrorand fall back to non-hybrid. Downstream feature access still surfaces paid-only features asPyViCareNotSupportedFeatureErrorthrough the cached service.dump_secure(): catchPyViCareNotPaidForErrorand emit a placeholder dump withdevice.dataUnavailableReason = "PACKAGE_NOT_PAID_FOR"so diagnostics produce a usable file instead of crashing.Tests
test_autoDetect_NotPaidFor_keeps_original: Vitocal auto-detects asHeatPumpdespite the API raisingPyViCareNotPaidForError.test_dump_secure_NotPaidFor_emits_placeholder: diagnostics dump contains thedataUnavailableReasonmarker and an emptydatalist.All 727 tests pass.