-
Couldn't load subscription status.
- Fork 20
Fix succeeded_power calculation in PV power distribution
#1217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| import logging | ||
| from datetime import timedelta | ||
|
|
||
| from frequenz.channels import Broadcast, LatestValueCache, Sender | ||
| from frequenz.channels import LatestValueCache, Sender | ||
| from frequenz.client.microgrid import ( | ||
| ApiClientError, | ||
| ComponentCategory, | ||
|
|
@@ -67,9 +67,6 @@ def __init__( | |
| self._component_data_caches: dict[ | ||
| ComponentId, LatestValueCache[InverterData] | ||
| ] = {} | ||
| self._target_power = Power.zero() | ||
| self._target_power_channel = Broadcast[Request](name="target_power") | ||
| self._target_power_tx = self._target_power_channel.new_sender() | ||
| self._task: asyncio.Task[None] | None = None | ||
|
|
||
| @override | ||
|
|
@@ -241,7 +238,7 @@ async def _set_api_power( # pylint: disable=too-many-locals | |
| failed_components=failed_components, | ||
| succeeded_components=succeeded_components, | ||
| failed_power=failed_power, | ||
| succeeded_power=self._target_power - failed_power, | ||
| succeeded_power=request.power - failed_power - remaining_power, | ||
| excess_power=remaining_power, | ||
| request=request, | ||
| ) | ||
|
|
@@ -250,7 +247,7 @@ async def _set_api_power( # pylint: disable=too-many-locals | |
| await self._results_sender.send( | ||
| Success( | ||
| succeeded_components=succeeded_components, | ||
| succeeded_power=self._target_power, | ||
| succeeded_power=request.power - remaining_power, | ||
|
||
| excess_power=remaining_power, | ||
| request=request, | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding a brief comment or updating the docstring here to clarify why the succeeded_power is calculated as request.power minus both the failed_power and remaining_power.