35 lines
914 B
Python
35 lines
914 B
Python
from __future__ import annotations
|
|
|
|
|
|
class HaClientError(Exception):
|
|
"""Basisklasse für HA-Client-Fehler."""
|
|
|
|
public_detail: str | None = None
|
|
|
|
|
|
class HaTimeoutError(HaClientError):
|
|
"""Zeitüberschreitung bei Request an Home Assistant."""
|
|
|
|
public_detail = "Home Assistant request timed out."
|
|
|
|
|
|
class HaHttpError(HaClientError):
|
|
"""Nicht erfolgreicher HTTP-Statuscode."""
|
|
|
|
public_detail = "Home Assistant request failed."
|
|
|
|
def __init__(self, status_code: int, message: str = "") -> None:
|
|
super().__init__(message)
|
|
self.status_code = status_code
|
|
|
|
|
|
class HaAuthError(HaHttpError):
|
|
"""Authentifizierung oder Berechtigung fehlgeschlagen."""
|
|
|
|
public_detail = "Home Assistant authentication failed."
|
|
|
|
|
|
class HaUnexpectedPayloadError(HaClientError):
|
|
"""Antwort hat nicht das erwartete Format."""
|
|
|
|
public_detail = "Home Assistant returned an unexpected payload." |