From d3a34c9cae31a1c2cca753369dce383603943ce6 Mon Sep 17 00:00:00 2001 From: davidusb-geek Date: Sun, 21 May 2023 15:34:00 +0200 Subject: [PATCH] Fix - Some minor fixes, see changelog --- CHANGELOG.md | 6 ++++++ src/emhass/utils.py | 4 ++-- src/emhass/web_server.py | 13 ++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10426b98..dbf31d4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.4.10] - 2023-05-21 +### Fix +- Fixed wrong name of new cost sensor. +- Fixed units of measurements of costs to €/kWh. +- Added color sequence to plot figures, now avery line should be plotted with a different color. + ## [0.4.9] - 2023-05-20 ### Fix - Updated default value for total number of days for ML model training. diff --git a/src/emhass/utils.py b/src/emhass/utils.py index 3c933a17..6b2c611f 100644 --- a/src/emhass/utils.py +++ b/src/emhass/utils.py @@ -136,8 +136,8 @@ def treat_runtimeparams(runtimeparams: str, params: str, retrieve_hass_conf: dic 'custom_batt_soc_forecast_id': {"entity_id": "sensor.soc_batt_forecast", "unit_of_measurement": "%", "friendly_name": "Battery SOC Forecast"}, 'custom_grid_forecast_id': {"entity_id": "sensor.p_grid_forecast", "unit_of_measurement": "W", "friendly_name": "Grid Power Forecast"}, 'custom_cost_fun_id': {"entity_id": "sensor.total_cost_fun_value", "unit_of_measurement": "", "friendly_name": "Total cost function value"}, - 'custom_unit_load_cost_id': {"entity_id": "sensor.unit_load_cost", "unit_of_measurement": "€", "friendly_name": "Unit Load Cost"}, - 'custom_unit_prod_price_id': {"entity_id": "sensor.unit_prod_price", "unit_of_measurement": "€", "friendly_name": "Unit Prod Price"}, + 'custom_unit_load_cost_id': {"entity_id": "sensor.unit_load_cost", "unit_of_measurement": "€/kWh", "friendly_name": "Unit Load Cost"}, + 'custom_unit_prod_price_id': {"entity_id": "sensor.unit_prod_price", "unit_of_measurement": "€/kWh", "friendly_name": "Unit Prod Price"}, 'custom_deferrable_forecast_id': custom_deferrable_forecast_id} if 'passed_data' in params.keys(): for key, value in default_passed_dict.items(): diff --git a/src/emhass/web_server.py b/src/emhass/web_server.py index 60d435a6..4a038ea4 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -30,16 +30,23 @@ def get_injection_dict(df, plot_size = 1366): # Create plots cols_p = [i for i in df.columns.to_list() if 'P_' in i] + n_colors = len(cols_p) + colors = px.colors.sample_colorscale("jet", [n/(n_colors -1) for n in range(n_colors)]) fig_0 = px.line(df[cols_p], title='Systems powers schedule after optimization results', - template='presentation', width=plot_size, height=0.5*plot_size, line_shape="hv") + template='presentation', width=plot_size, height=0.5*plot_size, line_shape="hv", + color_discrete_sequence=colors) fig_0.update_layout(xaxis_title='Timestamp', yaxis_title='System powers (W)') if 'SOC_opt' in df.columns.to_list(): fig_1 = px.line(df['SOC_opt'], title='Battery state of charge schedule after optimization results', - template='presentation', width=plot_size, height=0.5*plot_size, line_shape="hv") + template='presentation', width=plot_size, height=0.5*plot_size, line_shape="hv", + color_discrete_sequence=colors) fig_1.update_layout(xaxis_title='Timestamp', yaxis_title='Battery SOC (%)') cols_cost = [i for i in df.columns.to_list() if 'cost_' in i or 'unit_' in i] + n_colors = len(cols_cost) + colors = px.colors.sample_colorscale("jet", [n/(n_colors -1) for n in range(n_colors)]) fig_2 = px.line(df[cols_cost], title='Systems costs obtained from optimization results', - template='presentation', width=plot_size, height=0.5*plot_size, line_shape="hv") + template='presentation', width=plot_size, height=0.5*plot_size, line_shape="hv", + color_discrete_sequence=colors) fig_2.update_layout(xaxis_title='Timestamp', yaxis_title='System costs (currency)') # Get full path to image image_path_0 = fig_0.to_html(full_html=False, default_width='75%')