From 236b47283a486f3164660fe4b0f811614109445c Mon Sep 17 00:00:00 2001 From: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Date: Thu, 1 Dec 2022 21:53:44 +0100 Subject: [PATCH] Fix bugs in tutorial and CLI scheduling trigger (#545) * Add missing timezone Signed-off-by: F.N. Claessen * Fix call to make_schedule Signed-off-by: F.N. Claessen * Ensure storage specs, also when make_schedule is called directly (i.e. no job) Signed-off-by: F.N. Claessen * One more missing timezone Signed-off-by: F.N. Claessen * Wrong timezone (only updated from utc to Europe/Amsterdam in #481) Signed-off-by: F.N. Claessen Signed-off-by: F.N. Claessen --- documentation/index.rst | 2 +- documentation/tut/toy-example-from-scratch.rst | 2 +- flexmeasures/cli/data_add.py | 12 +++++++----- flexmeasures/data/services/scheduling.py | 2 ++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/documentation/index.rst b/documentation/index.rst index ed0c6078e..0abdf5031 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -40,7 +40,7 @@ A tiny, but complete example: Let's install FlexMeasures from scratch. Then, usi $ export SQLALCHEMY_DATABASE_URI="postgresql://postgres:docker@127.0.0.1:5433/flexmeasures-db" && export SECRET_KEY=notsecret $ flexmeasures db upgrade # create tables $ flexmeasures add toy-account --kind battery # setup account & a user, a battery (Id 2) and a market (Id 3) - $ flexmeasures add beliefs --sensor-id 3 --source toy-user prices-tomorrow.csv # load prices, also possible per API + $ flexmeasures add beliefs --sensor-id 3 --source toy-user prices-tomorrow.csv --timezone utc # load prices, also possible per API $ flexmeasures add schedule --sensor-id 2 --consumption-price-sensor 3 \ --start ${TOMORROW}T07:00+01:00 --duration PT12H \ --soc-at-start 50% --roundtrip-efficiency 90% # this is also possible per API diff --git a/documentation/tut/toy-example-from-scratch.rst b/documentation/tut/toy-example-from-scratch.rst index 0718b3172..b9996241f 100644 --- a/documentation/tut/toy-example-from-scratch.rst +++ b/documentation/tut/toy-example-from-scratch.rst @@ -19,7 +19,7 @@ Below are the ``flexmeasures`` CLI commands we'll run, and which we'll explain s # setup an account with a user, a battery (Id 2) and a market (Id 3) $ flexmeasures add toy-account --kind battery # load prices to optimise the schedule against - $ flexmeasures add beliefs --sensor-id 3 --source toy-user prices-tomorrow.csv + $ flexmeasures add beliefs --sensor-id 3 --source toy-user prices-tomorrow.csv --timezone utc # make the schedule $ flexmeasures add schedule --sensor-id 2 --consumption-price-sensor 3 \ --start ${TOMORROW}T07:00+01:00 --duration PT12H \ diff --git a/flexmeasures/cli/data_add.py b/flexmeasures/cli/data_add.py index f91244a03..de89a99d5 100755 --- a/flexmeasures/cli/data_add.py +++ b/flexmeasures/cli/data_add.py @@ -1015,11 +1015,13 @@ def create_schedule( end=end, belief_time=server_now(), resolution=power_sensor.event_resolution, - soc_at_start=soc_at_start, - soc_targets=soc_targets, - soc_min=soc_min, - soc_max=soc_max, - roundtrip_efficiency=roundtrip_efficiency, + storage_specs=dict( + soc_at_start=soc_at_start, + soc_targets=soc_targets, + soc_min=soc_min, + soc_max=soc_max, + roundtrip_efficiency=roundtrip_efficiency, + ), consumption_price_sensor=consumption_price_sensor, production_price_sensor=production_price_sensor, ) diff --git a/flexmeasures/data/services/scheduling.py b/flexmeasures/data/services/scheduling.py index 510c59b4a..497bf7ba5 100644 --- a/flexmeasures/data/services/scheduling.py +++ b/flexmeasures/data/services/scheduling.py @@ -144,6 +144,8 @@ def make_schedule( % sensor.generic_asset.generic_asset_type ) + storage_specs = ensure_storage_specs(storage_specs, sensor, start, end, resolution) + consumption_schedule = scheduler().schedule( sensor, start,