Skip to content

Commit

Permalink
Merge pull request #39 from klejejs/fix/installation-fetching
Browse files Browse the repository at this point in the history
Fix issues with fetching Thermia heat pumps
  • Loading branch information
klejejs authored Nov 27, 2024
2 parents 67096d5 + f31ce5c commit 08aaf32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ThermiaOnlineAPI/api/ThermiaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions ThermiaOnlineAPI/tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 08aaf32

Please sign in to comment.