From 505921bee5ad6343e616d57b8fdd447f5d9f6490 Mon Sep 17 00:00:00 2001 From: David HERNANDEZ Date: Sun, 12 Jun 2022 18:35:55 +0200 Subject: [PATCH] Fix - Fixed variables names problem fir mixed forecasts and prepared new version --- CHANGELOG.md | 6 +++++- docs/conf.py | 2 +- setup.py | 2 +- src/emhass/forecast.py | 6 ++---- tests/test_forecast.py | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 414405ca..9012d110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.3.17] - 2022-06-12 +### Fix +- Fixed wrong variables names for mixed forecasts. + ## [0.3.16] - 2022-06-10 ### Improvement - Improving documentation, added "what is this" section and added some infographics. @@ -13,7 +17,7 @@ ## [0.3.14] - 2022-06-05 ### Improvement -- Added one more table to the weu showing the cost totals. +- Added one more table to the webui showing the cost totals. ### Fix - Fixed wrong type error when serializing numpy ints. Converted ints to Python type. diff --git a/docs/conf.py b/docs/conf.py index 8dc6be9c..435a5cb1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'David HERNANDEZ' # The full version, including alpha/beta/rc tags -release = '0.3.16' +release = '0.3.17' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 95c1d812..3e50043f 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='emhass', # Required - version='0.3.16', # Required + version='0.3.17', # Required description='An Energy Management System for Home Assistant', # Optional long_description=long_description, # Optional long_description_content_type='text/markdown', # Optional (see note above) diff --git a/src/emhass/forecast.py b/src/emhass/forecast.py index e737949f..af93056a 100644 --- a/src/emhass/forecast.py +++ b/src/emhass/forecast.py @@ -350,8 +350,7 @@ def get_power_from_weather(self, df_weather: pd.DataFrame, if set_mix_forecast: P_PV_forecast = forecast.get_mix_forecast( df_now, P_PV_forecast, - self.params['passed_data']['alpha'], self.params['passed_data']['beta'], - 'sensor.power_photovoltaics') + self.params['passed_data']['alpha'], self.params['passed_data']['beta'], self.var_PV) return P_PV_forecast @@ -537,8 +536,7 @@ def get_load_forecast(self, days_min_load_forecast: Optional[int] = 3, method: O if set_mix_forecast: P_Load_forecast = forecast.get_mix_forecast( df_now, P_Load_forecast, - self.params['passed_data']['alpha'], self.params['passed_data']['beta'], - 'sensor.power_load_no_var_loads') + self.params['passed_data']['alpha'], self.params['passed_data']['beta'], self.var_load_new) return P_Load_forecast diff --git a/tests/test_forecast.py b/tests/test_forecast.py index 9595cf68..374d5551 100644 --- a/tests/test_forecast.py +++ b/tests/test_forecast.py @@ -188,6 +188,18 @@ def test_get_power_from_weather(self): self.assertIsInstance(P_PV_forecast.index.dtype, pd.core.dtypes.dtypes.DatetimeTZDtype) self.assertEqual(P_PV_forecast.index.tz, self.fcst.time_zone) self.assertEqual(len(self.df_weather_scrap), len(P_PV_forecast)) + # Test the mixed forecast + params = json.dumps({'passed_data':{'alpha':0.5,'beta':0.5}}) + df_input_data = self.input_data_dict['rh'].df_final.copy() + self.fcst = forecast(self.retrieve_hass_conf, self.optim_conf, self.plant_conf, + params, root, logger, get_data_from_file=self.get_data_from_file) + df_weather_scrap = self.fcst.get_weather_forecast(method='scrapper') + P_PV_forecast = self.fcst.get_power_from_weather(df_weather_scrap, set_mix_forecast=True, df_now=df_input_data) + self.assertIsInstance(P_PV_forecast, pd.core.series.Series) + self.assertIsInstance(P_PV_forecast.index, pd.core.indexes.datetimes.DatetimeIndex) + self.assertIsInstance(P_PV_forecast.index.dtype, pd.core.dtypes.dtypes.DatetimeTZDtype) + self.assertEqual(P_PV_forecast.index.tz, self.fcst.time_zone) + self.assertEqual(len(self.df_weather_scrap), len(P_PV_forecast)) def test_get_load_forecast(self): self.P_load_forecast = self.fcst.get_load_forecast() @@ -197,6 +209,17 @@ def test_get_load_forecast(self): self.assertEqual(self.P_load_forecast.index.tz, self.fcst.time_zone) self.assertEqual(len(self.P_PV_forecast), len(self.P_load_forecast)) print(">> The length of the load forecast = "+str(len(self.P_load_forecast))) + # Test the mixed forecast + params = json.dumps({'passed_data':{'alpha':0.5,'beta':0.5}}) + df_input_data = self.input_data_dict['rh'].df_final.copy() + self.fcst = forecast(self.retrieve_hass_conf, self.optim_conf, self.plant_conf, + params, root, logger, get_data_from_file=self.get_data_from_file) + self.P_load_forecast = self.fcst.get_load_forecast(set_mix_forecast=True, df_now=df_input_data) + self.assertIsInstance(self.P_load_forecast, pd.core.series.Series) + self.assertIsInstance(self.P_load_forecast.index, pd.core.indexes.datetimes.DatetimeIndex) + self.assertIsInstance(self.P_load_forecast.index.dtype, pd.core.dtypes.dtypes.DatetimeTZDtype) + self.assertEqual(self.P_load_forecast.index.tz, self.fcst.time_zone) + self.assertEqual(len(self.P_PV_forecast), len(self.P_load_forecast)) def test_get_load_cost_forecast(self): df_input_data = self.fcst.get_load_cost_forecast(self.df_input_data)