Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@
## Bug Fixes

- When using the new wall clock timer in the resampmler, it will now resync to the system time if it drifts away for more than a resample period, and do dynamic adjustments to the timer if the monotonic clock has a small drift compared to the wall clock.

- A power distributor logging issue is fixed, that was causing the power for multiple batteries connected to the same inverter to be reported incorrectly.
Original file line number Diff line number Diff line change
Expand Up @@ -266,25 +266,34 @@ async def _distribute_power(
Result from the microgrid API.
"""
distributed_power_value = request.power - distribution.remaining_power
battery_distribution: dict[ComponentId, Power] = {}
battery_distribution: dict[frozenset[ComponentId], Power] = {}
battery_ids: set[ComponentId] = set()
for inverter_id, dist in distribution.distribution.items():
for battery_id in self._inv_bats_map[inverter_id]:
battery_distribution[battery_id] = (
battery_distribution.get(battery_id, Power.zero()) + dist
)
_logger.debug(
"Distributing power %s between the batteries %s",
distributed_power_value,
str(battery_distribution),
)
battery_ids.add(battery_id)
battery_distribution[self._inv_bats_map[inverter_id]] = dist
if _logger.isEnabledFor(logging.DEBUG):
_logger.debug(
"Distributing power %s between the batteries: %s",
distributed_power_value,
", ".join(
(
str(next(iter(cids)))
if len(cids) == 1
else f"({', '.join(str(cid) for cid in cids)})"
)
+ f": {power}"
for cids, power in battery_distribution.items()
),
)

failed_power, failed_batteries = await self._set_distributed_power(
distribution, self._api_power_request_timeout
)

response: Success | PartialFailure
if len(failed_batteries) > 0:
succeed_batteries = set(battery_distribution.keys()) - failed_batteries
succeed_batteries = battery_ids - failed_batteries
response = PartialFailure(
request=request,
succeeded_power=distributed_power_value - failed_power,
Expand All @@ -294,7 +303,7 @@ async def _distribute_power(
excess_power=distribution.remaining_power,
)
else:
succeed_batteries = set(battery_distribution.keys())
succeed_batteries = battery_ids
response = Success(
request=request,
succeeded_power=distributed_power_value,
Expand Down