Skip to content
Merged
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
12 changes: 11 additions & 1 deletion airos/airos8.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ConnectionSetupError,
DataMissingError,
DeviceConnectionError,
KeyDataMissingError,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -203,7 +204,16 @@ async def status(self) -> dict:
if response.status == 200:
try:
response_text = await response.text()
return json.loads(response_text)
response_json = json.loads(response_text)
if (
"host" not in response_json
or "device_id" not in response_json["host"]
):
logger.error(
"Source data missing 'host' or 'device_id' keys"
)
raise KeyDataMissingError from None
return response_json
except json.JSONDecodeError:
logger.exception(
"JSON Decode Error in authenticated status response"
Expand Down
4 changes: 4 additions & 0 deletions airos/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ class DataMissingError(AirOSException):
"""Raised when expected data is missing."""


class KeyDataMissingError(AirOSException):
"""Raised when return data is missing critical keys."""


class DeviceConnectionError(AirOSException):
"""Raised when unable to connect."""
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "airos"
version = "0.1.0"
version = "0.1.1"
license = "MIT"
description = "Ubiquity airOS module(s) for Python 3."
readme = "README.md"
Expand Down