Complete custom_components/perfectdraft/ with: - Async API client (auth, refresh, machine polling) - Config flow with reCAPTCHA v3 external step - DataUpdateCoordinator for shared polling - Sensor entities (temperature, % remaining, days to expiry, keg name) - Image entity for keg artwork - HACS-compliant packaging (manifest.json, hacs.json, translations) - Configurable polling interval via OptionsFlow - Reauth flow for expired refresh tokens Group 8 (manual testing) deferred — requires live HA instance. Made-with: Cursor
22 lines
666 B
Python
22 lines
666 B
Python
"""Exceptions for the PerfectDraft integration."""
|
|
|
|
|
|
class PerfectDraftError(Exception):
|
|
"""Base exception for PerfectDraft."""
|
|
|
|
|
|
class AuthenticationError(PerfectDraftError):
|
|
"""Raised when authentication fails (bad credentials, expired refresh token, reCAPTCHA rejection)."""
|
|
|
|
|
|
class PerfectDraftApiError(PerfectDraftError):
|
|
"""Raised on non-auth API errors (4xx/5xx)."""
|
|
|
|
def __init__(self, status: int, message: str = "") -> None:
|
|
super().__init__(f"API error {status}: {message}")
|
|
self.status = status
|
|
|
|
|
|
class PerfectDraftConnectionError(PerfectDraftError):
|
|
"""Raised when the API is unreachable (network error, timeout)."""
|