roborock.exceptions

Roborock exceptions.

  1"""Roborock exceptions."""
  2
  3from enum import Enum
  4from typing import Any
  5
  6
  7class RoborockException(Exception):
  8    """Class for Roborock exceptions."""
  9
 10
 11class RoborockTimeout(RoborockException):
 12    """Class for Roborock timeout exceptions."""
 13
 14
 15class RoborockConnectionException(RoborockException):
 16    """Class for Roborock connection exceptions."""
 17
 18
 19class RoborockBackoffException(RoborockException):
 20    """Class for Roborock exceptions when many retries were made."""
 21
 22
 23class VacuumError(RoborockException):
 24    """Class for vacuum errors."""
 25
 26
 27class CommandVacuumError(RoborockException):
 28    """Class for command vacuum errors."""
 29
 30    def __init__(self, command: str | None, vacuum_error: VacuumError):
 31        self.message = f"{command or 'unknown'}: {str(vacuum_error)}"
 32        super().__init__(self.message)
 33
 34
 35class UnknownMethodError(RoborockException):
 36    """Class for an invalid method being sent."""
 37
 38
 39class RoborockAccountDoesNotExist(RoborockException):
 40    """Class for Roborock account does not exist exceptions."""
 41
 42
 43class RoborockUrlException(RoborockException):
 44    """Class for being unable to get the URL for the Roborock account."""
 45
 46
 47class RoborockInvalidCode(RoborockException):
 48    """Class for Roborock invalid code exceptions."""
 49
 50
 51class RoborockInvalidEmail(RoborockException):
 52    """Class for Roborock invalid formatted email exceptions."""
 53
 54
 55class RoborockInvalidUserAgreement(RoborockException):
 56    """Class for Roborock invalid user agreement exceptions."""
 57
 58
 59class RoborockNoUserAgreement(RoborockException):
 60    """Class for Roborock no user agreement exceptions."""
 61
 62
 63class RoborockInvalidCredentials(RoborockException):
 64    """Class for Roborock credentials have expired or changed."""
 65
 66
 67class RoborockTooFrequentCodeRequests(RoborockException):
 68    """Class for Roborock too frequent code requests exceptions."""
 69
 70
 71class RoborockMissingParameters(RoborockException):
 72    """Class for Roborock missing parameters exceptions."""
 73
 74
 75class RoborockTooManyRequest(RoborockException):
 76    """Class for Roborock too many request exceptions."""
 77
 78
 79class RoborockRateLimit(RoborockException):
 80    """Class for our rate limits exceptions."""
 81
 82
 83class RoborockNoResponseFromBaseURL(RoborockException):
 84    """We could not find an url that had a record of the given account."""
 85
 86
 87class RoborockDeviceBusy(RoborockException):
 88    """Class for Roborock device busy exceptions."""
 89
 90
 91class RoborockInvalidStatus(RoborockException):
 92    """Class for Roborock invalid status exceptions (device action locked)."""
 93
 94
 95class RoborockUnsupportedFeature(RoborockException):
 96    """Class for Roborock unsupported feature exceptions."""
 97
 98
 99class RoborockParsingException(RoborockException):
100    """Class for Roborock exceptions when parsing device responses."""
101
102    def __init__(self, trait_name: str, command: Enum | str, payload: Any, inner_error: Exception | str) -> None:
103        cmd_name = command.name if isinstance(command, Enum) else str(command)
104        self.message = (
105            f"Failed to parse {cmd_name} response for {trait_name}. Payload: {payload!r} Error: {inner_error!r}"
106        )
107        super().__init__(self.message)
class RoborockException(builtins.Exception):
8class RoborockException(Exception):
9    """Class for Roborock exceptions."""

Class for Roborock exceptions.

class RoborockTimeout(RoborockException):
12class RoborockTimeout(RoborockException):
13    """Class for Roborock timeout exceptions."""

Class for Roborock timeout exceptions.

class RoborockConnectionException(RoborockException):
16class RoborockConnectionException(RoborockException):
17    """Class for Roborock connection exceptions."""

Class for Roborock connection exceptions.

class RoborockBackoffException(RoborockException):
20class RoborockBackoffException(RoborockException):
21    """Class for Roborock exceptions when many retries were made."""

Class for Roborock exceptions when many retries were made.

class VacuumError(RoborockException):
24class VacuumError(RoborockException):
25    """Class for vacuum errors."""

Class for vacuum errors.

class CommandVacuumError(RoborockException):
28class CommandVacuumError(RoborockException):
29    """Class for command vacuum errors."""
30
31    def __init__(self, command: str | None, vacuum_error: VacuumError):
32        self.message = f"{command or 'unknown'}: {str(vacuum_error)}"
33        super().__init__(self.message)

Class for command vacuum errors.

CommandVacuumError(command: str | None, vacuum_error: VacuumError)
31    def __init__(self, command: str | None, vacuum_error: VacuumError):
32        self.message = f"{command or 'unknown'}: {str(vacuum_error)}"
33        super().__init__(self.message)
message
class UnknownMethodError(RoborockException):
36class UnknownMethodError(RoborockException):
37    """Class for an invalid method being sent."""

Class for an invalid method being sent.

class RoborockAccountDoesNotExist(RoborockException):
40class RoborockAccountDoesNotExist(RoborockException):
41    """Class for Roborock account does not exist exceptions."""

Class for Roborock account does not exist exceptions.

class RoborockUrlException(RoborockException):
44class RoborockUrlException(RoborockException):
45    """Class for being unable to get the URL for the Roborock account."""

Class for being unable to get the URL for the Roborock account.

class RoborockInvalidCode(RoborockException):
48class RoborockInvalidCode(RoborockException):
49    """Class for Roborock invalid code exceptions."""

Class for Roborock invalid code exceptions.

class RoborockInvalidEmail(RoborockException):
52class RoborockInvalidEmail(RoborockException):
53    """Class for Roborock invalid formatted email exceptions."""

Class for Roborock invalid formatted email exceptions.

class RoborockInvalidUserAgreement(RoborockException):
56class RoborockInvalidUserAgreement(RoborockException):
57    """Class for Roborock invalid user agreement exceptions."""

Class for Roborock invalid user agreement exceptions.

class RoborockNoUserAgreement(RoborockException):
60class RoborockNoUserAgreement(RoborockException):
61    """Class for Roborock no user agreement exceptions."""

Class for Roborock no user agreement exceptions.

class RoborockInvalidCredentials(RoborockException):
64class RoborockInvalidCredentials(RoborockException):
65    """Class for Roborock credentials have expired or changed."""

Class for Roborock credentials have expired or changed.

class RoborockTooFrequentCodeRequests(RoborockException):
68class RoborockTooFrequentCodeRequests(RoborockException):
69    """Class for Roborock too frequent code requests exceptions."""

Class for Roborock too frequent code requests exceptions.

class RoborockMissingParameters(RoborockException):
72class RoborockMissingParameters(RoborockException):
73    """Class for Roborock missing parameters exceptions."""

Class for Roborock missing parameters exceptions.

class RoborockTooManyRequest(RoborockException):
76class RoborockTooManyRequest(RoborockException):
77    """Class for Roborock too many request exceptions."""

Class for Roborock too many request exceptions.

class RoborockRateLimit(RoborockException):
80class RoborockRateLimit(RoborockException):
81    """Class for our rate limits exceptions."""

Class for our rate limits exceptions.

class RoborockNoResponseFromBaseURL(RoborockException):
84class RoborockNoResponseFromBaseURL(RoborockException):
85    """We could not find an url that had a record of the given account."""

We could not find an url that had a record of the given account.

class RoborockDeviceBusy(RoborockException):
88class RoborockDeviceBusy(RoborockException):
89    """Class for Roborock device busy exceptions."""

Class for Roborock device busy exceptions.

class RoborockInvalidStatus(RoborockException):
92class RoborockInvalidStatus(RoborockException):
93    """Class for Roborock invalid status exceptions (device action locked)."""

Class for Roborock invalid status exceptions (device action locked).

class RoborockUnsupportedFeature(RoborockException):
96class RoborockUnsupportedFeature(RoborockException):
97    """Class for Roborock unsupported feature exceptions."""

Class for Roborock unsupported feature exceptions.

class RoborockParsingException(RoborockException):
100class RoborockParsingException(RoborockException):
101    """Class for Roborock exceptions when parsing device responses."""
102
103    def __init__(self, trait_name: str, command: Enum | str, payload: Any, inner_error: Exception | str) -> None:
104        cmd_name = command.name if isinstance(command, Enum) else str(command)
105        self.message = (
106            f"Failed to parse {cmd_name} response for {trait_name}. Payload: {payload!r} Error: {inner_error!r}"
107        )
108        super().__init__(self.message)

Class for Roborock exceptions when parsing device responses.

RoborockParsingException( trait_name: str, command: enum.Enum | str, payload: Any, inner_error: Exception | str)
103    def __init__(self, trait_name: str, command: Enum | str, payload: Any, inner_error: Exception | str) -> None:
104        cmd_name = command.name if isinstance(command, Enum) else str(command)
105        self.message = (
106            f"Failed to parse {cmd_name} response for {trait_name}. Payload: {payload!r} Error: {inner_error!r}"
107        )
108        super().__init__(self.message)
message