diff --git a/src/pyowletapi/api.py b/src/pyowletapi/api.py index 6d830f2..e96402d 100644 --- a/src/pyowletapi/api.py +++ b/src/pyowletapi/api.py @@ -10,6 +10,8 @@ OwletAuthenticationError, OwletConnectionError, OwletDevicesError, + OwletEmailError, + OwletPasswordError, OwletError, ) from .const import REGION_INFO @@ -165,6 +167,12 @@ async def password_verification(self) -> None: case 400: message = response_json["error"]["message"] match message.split(":")[0]: + case "INVALID_EMAIL": + raise OwletEmailError("Invalid email address") + case "EMAIL_NOT_FOUND": + raise OwletEmailError("Email not found") + case "INVALID_PASSWORD": + raise OwletPasswordError("Invalid password") case "INVALID_LOGIN_CREDENTIALS": raise OwletCredentialsError( "Invalid login credentials", diff --git a/src/pyowletapi/exceptions.py b/src/pyowletapi/exceptions.py index e067be2..cfc4bdf 100644 --- a/src/pyowletapi/exceptions.py +++ b/src/pyowletapi/exceptions.py @@ -16,3 +16,11 @@ class OwletCredentialsError(OwletError): class OwletDevicesError(OwletError): """when no devices are found.""" + + +class OwletEmailError(OwletCredentialsError): + """When the provided email is invalid or unknown.""" + + +class OwletPasswordError(OwletCredentialsError): + """When the provided password is invalid.""" diff --git a/src/pyowletapi/sock.py b/src/pyowletapi/sock.py index 0ee1fb5..ead54f4 100644 --- a/src/pyowletapi/sock.py +++ b/src/pyowletapi/sock.py @@ -295,3 +295,21 @@ async def control_base_station(self, on: bool) -> bool: ) return True if response else False + + async def acknowledge_alert(self) -> bool: + """ + Sends the command used by the official app to pause an active alert. + + Returns + ------- + (bool):Was the command successful + """ + + payload = json.dumps({"ts": int(time.time())}) + data = {"datapoint": {"metadata": {}, "value": payload}} + + response = await self._api.post_command( + self.serial, "ALRT_PAUSE_CMD", data + ) + + return bool(response)