From 5204e02f824db2581eba59d4c6a4cc3a3e77e901 Mon Sep 17 00:00:00 2001 From: Johan Zander Date: Sun, 7 Jun 2026 20:19:05 +0200 Subject: [PATCH 1/2] Fix incorrect return type annotation for plant_list The method returns a dict (with 'data' and 'totalData' keys) from the API's "back" field, not a list. The annotation incorrectly stated list[dict[str, Any]]. Co-Authored-By: Claude Opus 4.6 --- growattServer/base_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/growattServer/base_api.py b/growattServer/base_api.py index cc0c7c1..7e38c04 100644 --- a/growattServer/base_api.py +++ b/growattServer/base_api.py @@ -178,7 +178,7 @@ def login(self, username: str, password: str, is_password_hashed: bool = False) }) return data - def plant_list(self, user_id: str) -> list[dict[str, Any]]: + def plant_list(self, user_id: str) -> dict[str, Any]: """ Get a list of plants connected to this account. @@ -186,7 +186,7 @@ def plant_list(self, user_id: str) -> list[dict[str, Any]]: user_id (str): The ID of the user. Returns: - list: A list of plants connected to the account. + dict: A dictionary containing 'data' (list of plants) and 'totalData' keys. Raises: Exception: If the request to the server fails. From 08e3aad01d7cc13fff897167eac67073a737e509 Mon Sep 17 00:00:00 2001 From: Johan Zander Date: Sun, 7 Jun 2026 20:26:14 +0200 Subject: [PATCH 2/2] Fix __get_all_devices return type and default value The method returns a list of devices (confirmed by TLX examples iterating over the result), not a dict. Fix annotation to list[dict[str, Any]] and default from {} to []. Co-Authored-By: Claude Opus 4.6 --- growattServer/base_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/growattServer/base_api.py b/growattServer/base_api.py index 7e38c04..1ef26bc 100644 --- a/growattServer/base_api.py +++ b/growattServer/base_api.py @@ -868,14 +868,14 @@ def inverter_list(self, plant_id: str) -> list[dict[str, Any]]: "This function may be deprecated in the future because naming is not correct, use device_list instead", DeprecationWarning, stacklevel=2) return self.device_list(plant_id) - def __get_all_devices(self, plant_id: str) -> dict[str, Any]: + def __get_all_devices(self, plant_id: str) -> list[dict[str, Any]]: """Get basic plant information with device list.""" response = self.session.get(self.get_url("newTwoPlantAPI.do"), params={"op": "getAllDeviceList", "plantId": plant_id, "language": 1}) - return response.json().get("deviceList", {}) + return response.json().get("deviceList", []) def device_list(self, plant_id: str) -> list[dict[str, Any]]: """Get a list of all devices connected to plant."""