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
4 changes: 3 additions & 1 deletion flexmeasures/data/models/planning/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,9 @@ def _compute_unresolved_targets(
# Devices without a state-of-charge sensor are included as long as a
# key can be derived from the power sensor's generic asset (or the
# power sensor itself).
power_sensor = flex_model_d.get("sensor")
# In single-sensor mode the flex_model entry has no "sensor" key;
# fall back to self.sensor (set when the scheduler was given a Sensor).
power_sensor = flex_model_d.get("sensor") or self.sensor
if (
power_sensor is not None
and hasattr(power_sensor, "generic_asset")
Expand Down
15 changes: 9 additions & 6 deletions flexmeasures/data/models/planning/tests/test_commitments.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ def test_two_flexible_assets_with_commodity(app, db):
schedules = scheduler.compute(skip_validation=True)

assert isinstance(schedules, list)
assert len(schedules) == 3 # 2 storage schedules + 1 commitment costs
assert (
len(schedules) == 4
) # 2 storage schedules + 1 commitment costs + 1 scheduling_result

# Extract schedules by type
storage_schedules = [
Expand All @@ -648,7 +650,6 @@ def test_two_flexible_assets_with_commodity(app, db):
)
battery_data = battery_schedule["data"]

# Get heat pump schedule
hp_schedule = next(
entry for entry in storage_schedules if entry["sensor"] == hp_power
)
Expand Down Expand Up @@ -790,7 +791,9 @@ def test_mixed_gas_and_electricity_assets(app, db):
schedules = scheduler.compute(skip_validation=True)

assert isinstance(schedules, list)
assert len(schedules) == 3 # 2 storage schedules + 1 commitment costs
assert (
len(schedules) == 4
) # 2 storage schedules + 1 commitment costs + 1 scheduling_result

# Extract schedules by type
storage_schedules = [
Expand Down Expand Up @@ -989,9 +992,9 @@ def test_two_devices_shared_stock(app, db):
"(device schedules, commitment costs, SOC)."
)

assert len(schedules) == 4, (
"Expected 4 outputs: two inverter schedules, one commitment_costs "
"object, and one state_of_charge schedule."
assert len(schedules) == 5, (
"Expected 5 outputs: two inverter schedules, one commitment_costs "
"object, one state_of_charge schedule, and one scheduling_result."
)

# ---- extract schedules
Expand Down
Loading