Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 294 post udi event bug rolling back due to integrity error #300

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions documentation/api/change_log.rst
Expand Up @@ -39,6 +39,16 @@ v2.0-0 | 2020-11-14
- REST endpoints for managing assets: `/assets/` (GET, POST) and `/asset/<id>` (GET, PATCH, DELETE).


v1.3-11 | 2022-01-05
""""""""""""""""""""

*Affects all versions since v1.3*.

- Changed the *postUdiEvent* endpoint:

- The recording time of new schedules triggered by calling the endpoint is now the time at which the endpoint was called, rather than the datetime of the sent state of charge (SOC).
- Introduced the "prior" field for the purpose of communicating an alternative recording time, thereby keeping support for simulations.

v1.3-10 | 2021-11-08
""""""""""""""""""""

Expand Down
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -11,6 +11,7 @@ New features

Bugfixes
-----------
* Fix recording time of schedules triggered by UDI events [see `PR #300 <http://www.github.com/FlexMeasures/flexmeasures/pull/300>`_]

Infrastructure / Support
----------------------
Expand Down
8 changes: 5 additions & 3 deletions flexmeasures/api/v1_3/implementations.py
@@ -1,5 +1,5 @@
# flake8: noqa: C901
from datetime import timedelta
from datetime import datetime, timedelta

import inflect
import isodate
Expand Down Expand Up @@ -35,6 +35,7 @@
type_accepted,
assets_required,
optional_duration_accepted,
optional_prior_accepted,
units_accepted,
parse_isodate_str,
)
Expand Down Expand Up @@ -215,8 +216,9 @@ def get_device_message_response(generic_asset_name_groups, duration):

@type_accepted("PostUdiEventRequest")
@units_accepted("State of charge", "kWh", "MWh")
@optional_prior_accepted()
@as_json
def post_udi_event_response(unit):
def post_udi_event_response(unit: str, prior: datetime):

if not has_assets():
current_app.logger.info("User doesn't seem to have any assets.")
Expand Down Expand Up @@ -360,7 +362,7 @@ def post_udi_event_response(unit):
start_of_schedule,
end_of_schedule,
resolution=resolution,
belief_time=datetime,
belief_time=prior, # server time if no prior time was sent
soc_at_start=value,
soc_targets=soc_targets,
udi_event_ea=form.get("event"),
Expand Down