From 697b514aa60f3a36c232c865c4bdfb8121f1223f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 14 Sep 2024 22:13:29 +0200 Subject: [PATCH] localapi: provide raw HTTP data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- aioairzone/const.py | 5 +++++ aioairzone/localapi.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/aioairzone/const.py b/aioairzone/const.py index aa54131..2646b41 100644 --- a/aioairzone/const.py +++ b/aioairzone/const.py @@ -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" diff --git a/aioairzone/localapi.py b/aioairzone/localapi.py index 87abfb4..6d4a8de 100644 --- a/aioairzone/localapi.py +++ b/aioairzone/localapi.py @@ -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, @@ -123,6 +128,7 @@ def __init__( RAW_DEMO: {}, RAW_DHW: {}, RAW_HVAC: {}, + RAW_HTTP: {}, RAW_INTEGRATION: {}, RAW_SYSTEMS: {}, RAW_VERSION: {}, @@ -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( @@ -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