Handle PACKAGE_NOT_PAID_FOR API error gracefully#737
Handle PACKAGE_NOT_PAID_FOR API error gracefully#737lackas wants to merge 1 commit intoopenviess:masterfrom
Conversation
Viessmann API returns errorType PACKAGE_NOT_PAID_FOR for users without a paid feature package. Previously this caused PyViCareInvalidDataError and crashed the integration setup. Now raises PyViCareNotPaidForError at the API layer, which is caught in the cached service and re-raised as PyViCareNotSupportedFeatureError. This allows downstream code (e.g. Home Assistant) to skip the feature gracefully instead of crashing during platform setup.
ced91fa to
5284d5b
Compare
| logger.error("Viessmann API denied access (PACKAGE_NOT_PAID_FOR). Features unavailable: %s", e) | ||
| if self.__cache is not None: | ||
| return self.__cache | ||
| raise PyViCareNotSupportedFeatureError("PACKAGE_NOT_PAID_FOR") |
There was a problem hiding this comment.
Usually we note in the exception which feature is unavailable, can you bring that in here somehow?
|
The 402 response from the API looks like this (from home-assistant/core#167367): {
"viErrorId": "00-d74916d71b5c410ddb3878970190f1ce-...",
"errorType": "PACKAGE_NOT_PAID_FOR",
"message": "",
"extendedPayload": {
"monetization": "User doesn't have access to the dan..."
}
}It's the bulk Without this fix, the response falls through to The reason I convert to Happy to adjust the exception message or structure if you have something specific in mind. |
Since late March 2026, Viessmann's API returns
PACKAGE_NOT_PAID_FOR(HTTP 402) for some users when fetching device features. This affects new installations across multiple countries (Germany, Poland, Ireland — see home-assistant/core#167367 and Viessmann community thread).Previously, this response lacked a
"data"key and triggeredPyViCareInvalidDataError, crashing the entire integration setup in Home Assistant.Approach:
PyViCareNotPaidForErrorexception, raised when the API returnserrorType: PACKAGE_NOT_PAID_FORViCareCachedService, this is caught separately from other API errors:PyViCareNotSupportedFeatureErrorThe re-raise as
PyViCareNotSupportedFeatureErroris a deliberate choice: HA already catches this exception in ~10 places to skip unsupported features. This means no HA-side changes are needed — the integration will set up cleanly but with zero entities for affected users, rather than crashing during platform setup.I considered keeping
PyViCareNotPaidForErrorall the way through, but that would require changes in everyis_supported()call path in HA. The distinct exception still exists at the library level for anyone who needs to distinguish "not paid" from "not supported" in their own code.