Skip to content

Commit 78cac48

Browse files
Fix bug in battery status (#237)
Inverter that was discharging was considered as not working. If inverter was discharging, then it was impossible to set any command until it changed state.
2 parents b148768 + e44fad8 commit 78cac48

File tree

9 files changed

+14
-16
lines changed

9 files changed

+14
-16
lines changed

examples/resampling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ async def run() -> None: # pylint: disable=too-many-locals
108108
second_stage_resampler.add_timeseries(average_chan.new_receiver(), _print_sample)
109109

110110
average_sender = average_chan.new_sender()
111+
111112
# Needed until channels Senders raises exceptions on errors
112113
async def sink_adapter(sample: Sample) -> None:
113114
assert await average_sender.send(sample)

noxfile.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import nox
1313

14-
FMT_DEPS = ["black", "isort"]
14+
FMT_DEPS = ["black==22.12.0", "isort==5.11.1"]
1515
DOCSTRING_DEPS = ["pydocstyle", "darglint"]
1616
PYTEST_DEPS = [
1717
"pytest",
@@ -21,7 +21,7 @@
2121
"time-machine",
2222
"async-solipsism",
2323
]
24-
MYPY_DEPS = ["mypy", "pandas-stubs", "grpc-stubs"]
24+
MYPY_DEPS = ["mypy==0.991", "pandas-stubs", "grpc-stubs"]
2525

2626

2727
def _source_file_paths(session: nox.Session) -> List[str]:
@@ -72,7 +72,13 @@ def ci_checks_max(session: nox.Session) -> None:
7272
session: the nox session.
7373
"""
7474
session.install(
75-
".[docs]", "pylint", "nox", *PYTEST_DEPS, *FMT_DEPS, *DOCSTRING_DEPS, *MYPY_DEPS
75+
".[docs]",
76+
"pylint==2.15.9",
77+
"nox",
78+
*PYTEST_DEPS,
79+
*FMT_DEPS,
80+
*DOCSTRING_DEPS,
81+
*MYPY_DEPS,
7682
)
7783

7884
formatting(session, False)
@@ -154,7 +160,7 @@ def pylint(session: nox.Session, install_deps: bool = True) -> None:
154160
if install_deps:
155161
# install the package itself as editable, so that it is possible to do
156162
# fast local tests with `nox -R -e pylint`.
157-
session.install("-e", ".[docs]", "pylint", "nox", *PYTEST_DEPS)
163+
session.install("-e", ".[docs]", "pylint==2.15.9", "nox", *PYTEST_DEPS)
158164

159165
paths = _source_file_paths(session)
160166
session.run(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies = [
2828
"frequenz-api-microgrid >= 0.11.0, < 0.12.0",
2929
"frequenz-channels >= 0.11.0, < 0.12.0",
3030
"google-api-python-client >= 2.71, < 3",
31-
"grpcio >= 1.51.1, < 2",
31+
"grpcio == 1.51.1",
3232
"grpcio-tools >= 1.51.1, < 2",
3333
"networkx >= 2.8, < 3",
3434
"pandas >= 1.5.2, < 2",

src/frequenz/sdk/_data_handling/time_series.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ def evaluate(
478478

479479
# Symbol metadata is not available, e.g. component category
480480
if symbol_mapping is None:
481-
482481
# Component data is available and up to date
483482
if cache_lookup_result.entry is not None:
484483
kwargs[symbol] = cache_lookup_result.entry.value

src/frequenz/sdk/actor/_data_sourcing/microgrid_api_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ async def _handle_data_stream(
347347

348348
def process_msg(data: Any) -> None:
349349
tasks = []
350-
for (extractor, senders) in stream_senders:
350+
for extractor, senders in stream_senders:
351351
for sender in senders:
352352
tasks.append(sender.send(Sample(data.timestamp, extractor(data))))
353353
asyncio.gather(*tasks)

src/frequenz/sdk/microgrid/_battery/_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class StatusTracker:
6161
InverterComponentState.COMPONENT_STATE_STANDBY,
6262
InverterComponentState.COMPONENT_STATE_IDLE,
6363
InverterComponentState.COMPONENT_STATE_CHARGING,
64-
InverterComponentState.COMPONENT_STATE_STANDBY,
64+
InverterComponentState.COMPONENT_STATE_DISCHARGING,
6565
}
6666

6767
def __init__(

tests/actor/test_power_distributing.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ async def test_power_distributor_invalid_battery_id(self) -> None:
386386
with mock.patch("asyncio.sleep", new_callable=AsyncMock) and mock.patch(
387387
"frequenz.sdk.microgrid.get", return_value=mock_microgrid
388388
):
389-
390389
distributor = PowerDistributingActor(service_channels)
391390

392391
# Mock that all requested batteries are working.
@@ -446,7 +445,6 @@ async def test_power_distributor_overlapping_batteries(self) -> None:
446445
with mock.patch("asyncio.sleep", new_callable=AsyncMock) and mock.patch(
447446
"frequenz.sdk.microgrid.get", return_value=mock_microgrid
448447
):
449-
450448
distributor = PowerDistributingActor(service_channels)
451449

452450
# Mock that all requested batteries are working.
@@ -545,7 +543,6 @@ async def test_power_distributor_one_user_adjust_power_consume(
545543
with mock.patch("asyncio.sleep", new_callable=AsyncMock) and mock.patch(
546544
"frequenz.sdk.microgrid.get", return_value=mock_microgrid
547545
):
548-
549546
distributor = PowerDistributingActor(service_channels)
550547

551548
# Mock that all requested batteries are working.
@@ -612,7 +609,6 @@ async def test_power_distributor_one_user_adjust_power_supply(
612609
with mock.patch("asyncio.sleep", new_callable=AsyncMock) and mock.patch(
613610
"frequenz.sdk.microgrid.get", return_value=mock_microgrid
614611
):
615-
616612
distributor = PowerDistributingActor(service_channels)
617613

618614
# Mock that all requested batteries are working.
@@ -679,7 +675,6 @@ async def test_power_distributor_one_user_adjust_power_success(
679675
with mock.patch("asyncio.sleep", new_callable=AsyncMock) and mock.patch(
680676
"frequenz.sdk.microgrid.get", return_value=mock_microgrid
681677
):
682-
683678
distributor = PowerDistributingActor(service_channels)
684679

685680
# Mock that all requested batteries are working.
@@ -739,7 +734,6 @@ async def test_not_all_batteries_are_working(
739734
with mock.patch("asyncio.sleep", new_callable=AsyncMock) and mock.patch(
740735
"frequenz.sdk.microgrid.get", return_value=mock_microgrid
741736
):
742-
743737
distributor = PowerDistributingActor({"user1": channel.service_handle})
744738

745739
# Mock that all requested batteries are working.

tests/data_ingestion/base_microgrid_data_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ async def _collect_microgrid_data(
129129
metric: [] for metric in metrics
130130
}
131131
while await select.ready():
132-
133132
for metric in metrics:
134133
if msg := getattr(select, metric):
135134
returned_data[metric].append(msg.inner)

tests/microgrid/test_graph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def _check_predecessors_and_successors(graph: gr.ComponentGraph) -> None:
3232
}
3333

3434
for conn in graph.connections():
35-
3635
if conn.end not in expected_predecessors:
3736
expected_predecessors[conn.end] = set()
3837
expected_predecessors[conn.end].add(components[conn.start])

0 commit comments

Comments
 (0)