Skip to content

Commit

Permalink
localapi: provide raw HTTP data
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
  • Loading branch information
Noltari committed Sep 14, 2024
1 parent be7a99b commit 697b514
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aioairzone/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,13 @@

RAW_DEMO: Final[str] = "demo"
RAW_DHW: Final[str] = "dhw"
RAW_HEADERS: Final[str] = "headers"
RAW_HVAC: Final[str] = "hvac"
RAW_HTTP: Final[str] = "http"
RAW_INTEGRATION: Final[str] = "integration"
RAW_QUIRKS: Final[str] = "quirks"
RAW_REASON: Final[str] = "reason"
RAW_STATUS: Final[str] = "status"
RAW_SYSTEMS: Final[str] = "systems"
RAW_VERSION: Final[str] = "version"
RAW_WEBSERVER: Final[str] = "webserver"
Expand Down
15 changes: 15 additions & 0 deletions aioairzone/localapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@
HTTP_QUIRK_VERSION,
RAW_DEMO,
RAW_DHW,
RAW_HEADERS,
RAW_HTTP,
RAW_HVAC,
RAW_INTEGRATION,
RAW_QUIRKS,
RAW_REASON,
RAW_STATUS,
RAW_SYSTEMS,
RAW_VERSION,
RAW_WEBSERVER,
Expand Down Expand Up @@ -123,6 +128,7 @@ def __init__(
RAW_DEMO: {},
RAW_DHW: {},
RAW_HVAC: {},
RAW_HTTP: {},
RAW_INTEGRATION: {},
RAW_SYSTEMS: {},
RAW_VERSION: {},
Expand Down Expand Up @@ -250,6 +256,13 @@ async def http_quirks_request(
self.handle_errors(resp_err)
raise APIError(f"HTTP status: {resp.status}")

if path.endswith(API_VERSION):
async with self._api_raw_data_lock:
self._api_raw_data[RAW_HTTP][RAW_HEADERS] = resp.header_map
self._api_raw_data[RAW_HTTP][RAW_REASON] = resp.reason
self._api_raw_data[RAW_HTTP][RAW_STATUS] = resp.status
self._api_raw_data[RAW_HTTP][RAW_VERSION] = resp.version

return cast(dict[str, Any], resp_json)

async def http_request(
Expand Down Expand Up @@ -336,6 +349,8 @@ async def check_feature_version(self) -> None:
if version_str is not None:
self.version = version_str
self.http_quirks_needed = Version(version_str) < HTTP_QUIRK_VERSION
async with self._api_raw_data_lock:
self._api_raw_data[RAW_HTTP][RAW_QUIRKS] = self.http_quirks_needed
except InvalidMethod:
pass

Expand Down

0 comments on commit 697b514

Please sign in to comment.