From 1ecc579cac360e7ec9cf0d3c914adad4e5586fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20H=C3=B6ning?= Date: Wed, 13 Aug 2025 18:09:05 +0200 Subject: [PATCH 1/4] feat: get asset types (uses FM#1663) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolas Höning --- src/flexmeasures_client/client.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/flexmeasures_client/client.py b/src/flexmeasures_client/client.py index 8042f005..c99c90ed 100644 --- a/src/flexmeasures_client/client.py +++ b/src/flexmeasures_client/client.py @@ -296,6 +296,20 @@ async def get_versions(self): return version_info + async def get_asset_types(self) -> list: + """Get the asset types currently supported by FlexMeasures server.""" + response, status = await self.request( + uri="assets/types", + method="GET", + ) + if not isinstance(response, list): + raise ContentTypeError( + f"Expected a list of asset types, but got {type(response)}", + ) + check_for_status(status, 200) + + return response + async def post_measurements( self, sensor_id: int, From f1421bbbb2c66e2af588e244b40b2d6a20af10c1 Mon Sep 17 00:00:00 2001 From: Mohamed Belhsan Hmida Date: Wed, 19 Nov 2025 00:27:55 +0100 Subject: [PATCH 2/4] style: remove empty space from line Signed-off-by: Mohamed Belhsan Hmida --- src/flexmeasures_client/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flexmeasures_client/client.py b/src/flexmeasures_client/client.py index 721df0bf..2b579f31 100644 --- a/src/flexmeasures_client/client.py +++ b/src/flexmeasures_client/client.py @@ -296,7 +296,7 @@ async def get_versions(self): ) return version_info - + async def get_asset_types(self) -> list: """Get the asset types currently supported by FlexMeasures server.""" response, status = await self.request( From 03f4af152ee3131da95538cb91d737c4feae4538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20H=C3=B6ning?= Date: Fri, 21 Nov 2025 23:41:01 +0100 Subject: [PATCH 3/4] describe API/function response in docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com> Signed-off-by: Nicolas Höning --- src/flexmeasures_client/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/flexmeasures_client/client.py b/src/flexmeasures_client/client.py index 2b579f31..714eae8b 100644 --- a/src/flexmeasures_client/client.py +++ b/src/flexmeasures_client/client.py @@ -298,7 +298,13 @@ async def get_versions(self): return version_info async def get_asset_types(self) -> list: - """Get the asset types currently supported by FlexMeasures server.""" + """ + Get the asset types currently supported by FlexMeasures server. + + Returns: + list[dict]: List of asset type objects, e.g., + [{"id": 1, "name": "solar", "description": "solar panel(s)"}] + """ response, status = await self.request( uri="assets/types", method="GET", From 0935c3eec7c7cee84060c87992a9a0187d258b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20H=C3=B6ning?= Date: Fri, 21 Nov 2025 23:44:08 +0100 Subject: [PATCH 4/4] first check response status, then type of data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolas Höning --- src/flexmeasures_client/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flexmeasures_client/client.py b/src/flexmeasures_client/client.py index 714eae8b..675ad7a6 100644 --- a/src/flexmeasures_client/client.py +++ b/src/flexmeasures_client/client.py @@ -300,7 +300,7 @@ async def get_versions(self): async def get_asset_types(self) -> list: """ Get the asset types currently supported by FlexMeasures server. - + Returns: list[dict]: List of asset type objects, e.g., [{"id": 1, "name": "solar", "description": "solar panel(s)"}] @@ -309,11 +309,11 @@ async def get_asset_types(self) -> list: uri="assets/types", method="GET", ) + check_for_status(status, 200) if not isinstance(response, list): raise ContentTypeError( f"Expected a list of asset types, but got {type(response)}", ) - check_for_status(status, 200) return response