Skip to content

Commit

Permalink
Fix MockMicrogrid add_chps method to can create chp without meter
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ela-kotulska-frequenz committed Aug 21, 2024
1 parent 09dbb75 commit fbb5fae
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tests/timeseries/mock_microgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,34 +362,31 @@ def add_chps(self, count: int, no_meters: bool = False) -> None:
no_meters: if True, do not add a meter for each CHP.
"""
for _ in range(count):
meter_id = self._id_increment * 10 + self.meter_id_suffix
chp_id = self._id_increment * 10 + self.chp_id_suffix
self._id_increment += 1

self.meter_ids.append(meter_id)
self.chp_ids.append(chp_id)

if not no_meters:
self._components.add(
Component(
meter_id,
ComponentCategory.METER,
)
)
self._components.add(
Component(
chp_id,
ComponentCategory.CHP,
)
)

self._start_meter_streaming(meter_id)
if no_meters:
self._connections.add(Connection(self._connect_to, chp_id))
else:
meter_id = self._id_increment * 10 + self.meter_id_suffix
self.meter_ids.append(meter_id)
self._components.add(
Component(
meter_id,
ComponentCategory.METER,
)
)
self._start_meter_streaming(meter_id)
self._connections.add(Connection(self._connect_to, meter_id))
self._connections.add(Connection(meter_id, chp_id))

self._id_increment += 1

def add_batteries(self, count: int, no_meter: bool = False) -> None:
"""Add batteries with connected inverters and meters to the microgrid.
Expand Down

0 comments on commit fbb5fae

Please sign in to comment.