From f31ce5cef744d8914a28a27625df8389444b7823 Mon Sep 17 00:00:00 2001 From: Krisjanis Lejejs Date: Wed, 27 Nov 2024 23:50:33 +0200 Subject: [PATCH] Fix issues with fetching Thermia heat pumps --- ThermiaOnlineAPI/api/ThermiaAPI.py | 6 ++++-- ThermiaOnlineAPI/tests/setup.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ThermiaOnlineAPI/api/ThermiaAPI.py b/ThermiaOnlineAPI/api/ThermiaAPI.py index d0f0d2a..a4a450f 100644 --- a/ThermiaOnlineAPI/api/ThermiaAPI.py +++ b/ThermiaOnlineAPI/api/ThermiaAPI.py @@ -78,7 +78,7 @@ def __init__(self, email, password): def get_devices(self): self.__check_token_validity() - url = self.configuration["apiBaseUrl"] + "/api/v1/InstallationsInfo/own" + url = self.configuration["apiBaseUrl"] + "/api/v1/installationsInfo" request = self.__session.get(url, headers=self.__default_request_headers) status = request.status_code @@ -91,10 +91,12 @@ def get_devices(self): ) return [] - return utils.get_response_json_or_log_and_raise_exception( + response = utils.get_response_json_or_log_and_raise_exception( request, "Error getting devices." ) + return response.get("items", []) + def get_device_by_id(self, device_id: str): self.__check_token_validity() diff --git a/ThermiaOnlineAPI/tests/setup.py b/ThermiaOnlineAPI/tests/setup.py index 4b4d4c1..1402310 100644 --- a/ThermiaOnlineAPI/tests/setup.py +++ b/ThermiaOnlineAPI/tests/setup.py @@ -43,8 +43,8 @@ def __mock_data_requests(requests_mock, test_data_file: str): test_data = parse_debug_file(f"{absolute_path}/debug_files/{test_data_file}") requests_mock.get( - f"{THERMIA_TEST_URL}/api/v1/InstallationsInfo/own", - json=[{**test_data["device_data"], "id": "test-id"}], + f"{THERMIA_TEST_URL}/api/v1/InstallationsInfo", + json={"items": [{**test_data["device_data"], "id": "test-id"}]}, ) requests_mock.get( f"{THERMIA_TEST_URL}/api/v1/installations/test-id",