Skip to content
Open
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: 1 addition & 1 deletion documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Infrastructure / Support

Bugfixes
-----------

* Fix ``StorageScheduler`` crash (``AttributeError: 'NoneType' object has no attribute 'event_resolution'``) when scheduling a site whose asset tree contains non-storage devices with only a ``power-capacity`` in their ``flex-model`` (no ``sensor`` key) [see `issue #2084 <https://github.com/FlexMeasures/flexmeasures/issues/2084>`_]

v0.31.2 | March 18, 2026
============================
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/data/models/planning/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ def _prepare(self, skip_validation: bool = False) -> tuple: # noqa: C901
device_constraints[d]["efficiency"] = storage_efficiency[d]

# Convert efficiency from sensor resolution to scheduling resolution
if sensor_d.event_resolution != timedelta(0):
if sensor_d is not None and sensor_d.event_resolution != timedelta(0):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of the case where the power sensor of the device is not mentioned in the flex-model of the API trigger message, but the device does have a storage-efficiency defined on the db flex-model.

The storage-efficiency will then become interpreted with respect to the scheduling resolution rather than the device's own power sensor resolution, and requesting the schedule in a different resolution would result in a different interpretation of the storage-efficiency over time.

This is a known shortcoming of our current implementation of the storage-efficiency (see #720), but your solution appears to me it might amplify the problem.

Four possible remedies I see going forward:

  1. Resolve Storage efficiency notation per any time unit. #720
  2. Keep requiring a sensor, but make it possible to define a power sensor in the db flex-model.
  3. If a storage-efficiency is defined in the db flex-model, and the corresponding power sensor is missing, throw a ValidationError.
  4. We document this shortcoming, for instance, in scheduling.rst under the storage-efficiency footnote, and move forward.

I'm assuming your device doesn't have a storage-efficiency, is that correct? Then 3 or 4 seem like a reasonable quick fix to me. Would you agree?

1 and/or 2 are the more long-term solutions, but they for sure require more work and whoever works on them might encounter complications along the way.

device_constraints[d]["efficiency"] **= (
resolution / sensor_d.event_resolution
)
Expand Down
Loading