Skip to content

Commit

Permalink
Backport PR #216: Fix device messages (#216)
Browse files Browse the repository at this point in the history
Fix cases where data retrieved from the database isn't already chronologically ordered. This bug caused device messages to possibly state a negative duration (in case the last value preceded the first one).

* Order power values chronologically in device messages

* Changelog entry
  • Loading branch information
Flix6x committed Oct 20, 2021
1 parent 4732062 commit d4c9ca6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -26,6 +26,7 @@ Bugfixes
-----------
* Fix (dev) CLI command for adding a GenericAssetType [see `PR #173 <http://www.github.com/SeitaBV/flexmeasures/pull/173>`_]
* Fix (dev) CLI command for adding a Sensor [see `PR #176 <http://www.github.com/SeitaBV/flexmeasures/pull/176>`_]
* Fix GetDeviceMessage to ensure chronological ordering of values [see `PR #216 <http://www.github.com/SeitaBV/flexmeasures/pull/216>`_]

Infrastructure / Support
----------------------
Expand Down
1 change: 1 addition & 0 deletions flexmeasures/api/v1_3/implementations.py
Expand Up @@ -149,6 +149,7 @@ def get_device_message_response(generic_asset_name_groups, duration):
.filter(Power.data_source_id == scheduler_source.id)
.filter(Power.datetime >= schedule_start)
.filter(Power.datetime < schedule_start + planning_horizon)
.order_by(Power.datetime.asc())
.all()
)
consumption_schedule = pd.Series(
Expand Down

0 comments on commit d4c9ca6

Please sign in to comment.