From 1c0054bea9279113694f50d1bbc0e5033c79233d Mon Sep 17 00:00:00 2001 From: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Date: Fri, 22 Jul 2022 00:26:07 +0200 Subject: [PATCH] Toy tutorial UI fixes (#466) Correct mistake in how the battery schedule is visualized in the UI and CLI (positive values indicate production, i.e. discharging). Also make what is shown on chart tooltips easier to the eye. * Switch interpretation of charging sensor to discharging for positive values Signed-off-by: F.N. Claessen * Stop using the SI prefix when formatting quantitative data values, now that we show the unit right next to the value Signed-off-by: F.N. Claessen * Avoid showing "null" versions for data source models Signed-off-by: F.N. Claessen * Changelog entry Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 1 + flexmeasures/cli/data_add.py | 2 +- flexmeasures/data/models/charts/belief_charts.py | 2 +- flexmeasures/data/models/data_sources.py | 5 ++++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index d54261042..e27ba1edf 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -20,6 +20,7 @@ Bugfixes * Do not fail asset page if entity addresses cannot be built [see `PR #457 `_] * Time scale axes in sensor data charts now match the requested date range, rather than stopping at the edge of the available data [see `PR #449 `_] * The docker-based tutorial now works with UI on all platforms (port 5000 did not expose on MacOS) [see `PR #465 `_] +* Fix interpretation of scheduling results in toy tutorial [see `PR #466 `_] Infrastructure / Support ---------------------- diff --git a/flexmeasures/cli/data_add.py b/flexmeasures/cli/data_add.py index 10e7a0d02..30bc20341 100755 --- a/flexmeasures/cli/data_add.py +++ b/flexmeasures/cli/data_add.py @@ -996,7 +996,7 @@ def add_toy_account(kind: str, name: str): ) # add charging sensor to battery charging_sensor = Sensor( - name="charging", + name="discharging", generic_asset=asset, unit="MW", timezone="Europe/Amsterdam", diff --git a/flexmeasures/data/models/charts/belief_charts.py b/flexmeasures/data/models/charts/belief_charts.py index 6f1570666..5bcc8344b 100644 --- a/flexmeasures/data/models/charts/belief_charts.py +++ b/flexmeasures/data/models/charts/belief_charts.py @@ -79,7 +79,7 @@ def chart_for_multiple_sensors( unit = sensor.unit if sensor.unit else "a.u." event_value_field_definition = dict( title=f"{capitalize(sensor.sensor_type)} ({unit})", - format=[".3s", unit], + format=[".3~r", unit], formatType="quantityWithUnitFormat", stack=None, **{ diff --git a/flexmeasures/data/models/data_sources.py b/flexmeasures/data/models/data_sources.py index f2b693a12..e51f5490e 100644 --- a/flexmeasures/data/models/data_sources.py +++ b/flexmeasures/data/models/data_sources.py @@ -88,9 +88,12 @@ def __str__(self): return self.description def to_dict(self) -> dict: + model_incl_version = self.model if self.model else "" + if self.model and self.version: + model_incl_version += f" ({self.version}" return dict( id=self.id, name=self.name, - model=f"{self.model} ({self.version})" if self.model else "", + model=model_incl_version, description=self.description, )