From 85ade3c3ef808e06bcefaa8d1965d0f0659599ba Mon Sep 17 00:00:00 2001 From: Sahas Subramanian Date: Mon, 11 Nov 2024 12:34:36 +0100 Subject: [PATCH 1/2] Add the `set_reactive_power` method Signed-off-by: Sahas Subramanian --- src/frequenz/client/microgrid/_client.py | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/frequenz/client/microgrid/_client.py b/src/frequenz/client/microgrid/_client.py index cf8fccde..9a0b894a 100644 --- a/src/frequenz/client/microgrid/_client.py +++ b/src/frequenz/client/microgrid/_client.py @@ -417,6 +417,34 @@ async def set_power( # noqa: DOC502 (raises ApiClientError indirectly) method_name="SetPowerActive", ) + async def set_reactive_power( # noqa: DOC502 (raises ApiClientError indirectly) + self, component_id: int, reactive_power_var: float + ) -> None: + """Send request to the Microgrid to set reactive power for component. + + Negative values are for inductive (lagging) power , and positive values are for + capacitive (leading) power. + + Args: + component_id: id of the component to set power. + reactive_power_var: reactive power to set for the component. + + Raises: + ApiClientError: If the are any errors communicating with the Microgrid API, + most likely a subclass of + [GrpcError][frequenz.client.microgrid.GrpcError]. + """ + await client.call_stub_method( + self, + lambda: self._async_stub.SetPowerReactive( + microgrid_pb2.SetPowerReactiveParam( + component_id=component_id, power=reactive_power_var + ), + timeout=int(DEFAULT_GRPC_CALL_TIMEOUT), + ), + method_name="SetPowerReactive", + ) + async def set_bounds( # noqa: DOC503 (raises ApiClientError indirectly) self, component_id: int, From f116afc7a5015ed2d3b009ea483c53f0ca093fbf Mon Sep 17 00:00:00 2001 From: Sahas Subramanian Date: Mon, 11 Nov 2024 12:38:44 +0100 Subject: [PATCH 2/2] Update release notes Signed-off-by: Sahas Subramanian --- RELEASE_NOTES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 392a36b8..a89c6396 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -17,6 +17,8 @@ - The client now inherits from `frequenz.client.base.BaseApiClient`, so it provides a few new features, like `disconnect()`ing or using it as a context manager. Please refer to the [`BaseApiClient` documentation](https://frequenz-floss.github.io/frequenz-client-base-python/latest/reference/frequenz/client/base/client/#frequenz.client.base.client.BaseApiClient) for more information on these features. +- The client now supports setting reactive power for components through the new `set_reactive_power` method. + ## Bug Fixes