Skip to content

Commit

Permalink
Fix - Fixed variables names problem fir mixed forecasts and prepared …
Browse files Browse the repository at this point in the history
…new version
  • Loading branch information
davidusb-geek committed Jun 12, 2022
1 parent f83d906 commit 505921b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/emhass/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions tests/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 505921b

Please sign in to comment.