Skip to content

Commit 7f24fa2

Browse files
Fix MockMicrogrid add_chps method to can create chp without meter
Previously if no_meter was True, meter was created but didn't send values. Now no meter is created. No tests are failing after this change Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent 18c0572 commit 7f24fa2

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

tests/timeseries/mock_microgrid.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,34 +362,31 @@ def add_chps(self, count: int, no_meters: bool = False) -> None:
362362
no_meters: if True, do not add a meter for each CHP.
363363
"""
364364
for _ in range(count):
365-
meter_id = self._id_increment * 10 + self.meter_id_suffix
366365
chp_id = self._id_increment * 10 + self.chp_id_suffix
367-
self._id_increment += 1
368-
369-
self.meter_ids.append(meter_id)
370366
self.chp_ids.append(chp_id)
371-
372-
if not no_meters:
373-
self._components.add(
374-
Component(
375-
meter_id,
376-
ComponentCategory.METER,
377-
)
378-
)
379367
self._components.add(
380368
Component(
381369
chp_id,
382370
ComponentCategory.CHP,
383371
)
384372
)
385-
386-
self._start_meter_streaming(meter_id)
387373
if no_meters:
388374
self._connections.add(Connection(self._connect_to, chp_id))
389375
else:
376+
meter_id = self._id_increment * 10 + self.meter_id_suffix
377+
self.meter_ids.append(meter_id)
378+
self._components.add(
379+
Component(
380+
meter_id,
381+
ComponentCategory.METER,
382+
)
383+
)
384+
self._start_meter_streaming(meter_id)
390385
self._connections.add(Connection(self._connect_to, meter_id))
391386
self._connections.add(Connection(meter_id, chp_id))
392387

388+
self._id_increment += 1
389+
393390
def add_batteries(self, count: int, no_meter: bool = False) -> None:
394391
"""Add batteries with connected inverters and meters to the microgrid.
395392

0 commit comments

Comments
 (0)