Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/pyowletapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
OwletAuthenticationError,
OwletConnectionError,
OwletDevicesError,
OwletEmailError,
OwletPasswordError,
OwletError,
)
from .const import REGION_INFO
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/pyowletapi/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
18 changes: 18 additions & 0 deletions src/pyowletapi/sock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)