@davidusb
When i did try again to forecast next 31 hours i got an ValueError: Shape of passed values is (14, 1), indices imply (7, 1):
2024-04-02 17:30:00,479 - web_server - INFO - Passed runtime parameters: {'load_cost_forecast': [0.07, 0.109, 0.146, 0.173, 0.172, 0.091, 0.071, 0.042, 0.071, 0.065, 0.061, 0.056, 0.073, 0.124, 0.167, 0.199, 0.198, 0.168, 0.158, 0.154, 0.149, 0.146, 0.143, 0.146, 0.15, 0.169, 0.191, 0.206, 0.18, 0.131, 0.115], 'prod_price_forecast': [0.009, 0.041, 0.071, 0.093, 0.093, 0.042, 0.026, 0.002, 0.025, 0.021, 0.017, 0.013, 0.027, 0.069, 0.088, 0.115, 0.114, 0.089, 0.081, 0.077, 0.074, 0.071, 0.069, 0.071, 0.075, 0.09, 0.108, 0.12, 0.099, 0.075, 0.061], 'prediction_horizon': 31, 'pv_power_forecast': [376, 232, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 151, 459, 907, 1427, 1844, 2111, 2195, 2108, 1958, 1461, 835, 410, 121, 0, 0, 0, 0], 'var_model': 'sensor.ss_load_power', 'var_load:': 'sensor.ss_load_power', 'delta_forecast': 20}
2024-04-02 17:30:00,480 - web_server - INFO - >> Setting input data dict
2024-04-02 17:30:00,480 - web_server - INFO - Setting up needed data
2024-04-02 17:30:00,483 - web_server - INFO - Retrieve hass get data method initiated...
2024-04-02 17:30:00,799 - web_server - INFO - Retrieving weather forecast data using method = list
2024-04-02 17:30:00,801 - web_server - INFO - Retrieving data from hass for load forecast using method = mlforecaster
2024-04-02 17:30:00,801 - web_server - INFO - Retrieve hass get data method initiated...
2024-04-02 17:30:01,626 - web_server - INFO - >> Performing naive MPC optimization...
2024-04-02 17:30:01,626 - web_server - INFO - Performing naive MPC optimization
2024-04-02 17:30:01,633 - web_server - ERROR - Exception on /action/naive-mpc-optim [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1463, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 872, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 870, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 855, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 145, in action_call
opt_res = naive_mpc_optim(input_data_dict, app.logger)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/command_line.py", line 273, in naive_mpc_optim
df_input_data_dayahead = input_data_dict['fcst'].get_load_cost_forecast(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/forecast.py", line 715, in get_load_cost_forecast
forecast_out = self.get_forecast_out_from_csv(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/forecast.py", line 530, in get_forecast_out_from_csv
forecast_out = pd.DataFrame(
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pandas/core/frame.py", line 758, in __init__
mgr = ndarray_to_mgr(
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pandas/core/internals/construction.py", line 337, in ndarray_to_mgr
_check_values_indices_shape_match(values, index, columns)
File "/usr/local/lib/python3.11/dist-packages/pandas/core/internals/construction.py", line 408, in _check_values_indices_shape_match
raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (14, 1), indices imply (7, 1)
There is data for each input for 31 hours.
Also MLforecast fit gave me error:
2024-04-02 17:35:51,930 - web_server - INFO - Passed runtime parameters: {'days_to_retrieve': 20, 'model_type': 'load_forecast', 'var_model': 'sensor.ss_load_power', 'num_lags': 24, 'split_date_delta': '48h', 'perform_backtest': 'True'}
2024-04-02 17:35:51,930 - web_server - INFO - >> Setting input data dict
2024-04-02 17:35:51,930 - web_server - INFO - Setting up needed data
2024-04-02 17:35:51,933 - web_server - INFO - Retrieve hass get data method initiated...
2024-04-02 17:35:51,937 - web_server - ERROR - The retrieved JSON is empty, A sensor:sensor.ss_load_power may have 0 days of history or passed sensor may not be correct
Could it be because of daylight saving time? Error occured after updating to 0.8.5
i do have data in sensor.ss_load_power
EDIT: Also dayahead is not working:
2024-04-02 17:40:07,717 - web_server - INFO - Passed runtime parameters: {'load_cost_forecast': [0.07, 0.109, 0.146, 0.173, 0.172, 0.091, 0.071, 0.042, 0.071, 0.065, 0.061, 0.056, 0.073, 0.124, 0.167, 0.199, 0.198, 0.168, 0.158, 0.154, 0.149, 0.146, 0.143, 0.146], 'prod_price_forecast': [0.009, 0.041, 0.071, 0.093, 0.093, 0.042, 0.026, 0.002, 0.025, 0.021, 0.017, 0.013, 0.027, 0.069, 0.088, 0.115, 0.114, 0.089, 0.081, 0.077, 0.074, 0.071, 0.069, 0.071], 'prediction_horizon': 24, 'pv_power_forecast': [376, 232, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 151, 459, 907, 1427, 1844, 2111, 2195, 2108, 1958, 1461, 835, 410, 121, 0, 0, 0, 0], 'var_model': 'sensor.ss_load_power', 'var_load:': 'sensor.ss_load_power', 'delta_forecast': 20}
2024-04-02 17:40:07,717 - web_server - INFO - >> Setting input data dict
2024-04-02 17:40:07,718 - web_server - INFO - Setting up needed data
2024-04-02 17:40:07,722 - web_server - ERROR - ERROR: The passed data is either not a list or the length is not correct, length should be 48
2024-04-02 17:40:07,723 - web_server - ERROR - Passed type is <class 'list'> and length is 31
2024-04-02 17:40:07,723 - web_server - ERROR - ERROR: The passed data is either not a list or the length is not correct, length should be 48
2024-04-02 17:40:07,724 - web_server - ERROR - Passed type is <class 'list'> and length is 24
2024-04-02 17:40:07,724 - web_server - ERROR - ERROR: The passed data is either not a list or the length is not correct, length should be 48
2024-04-02 17:40:07,724 - web_server - ERROR - Passed type is <class 'list'> and length is 24
2024-04-02 17:40:07,735 - web_server - INFO - Retrieving weather forecast data using method = scrapper
2024-04-02 17:40:08,717 - web_server - ERROR - Exception on /action/dayahead-optim [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1463, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 872, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 870, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 855, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 108, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/command_line.py", line 91, in set_input_data_dict
df_weather = fcst.get_weather_forecast(method=optim_conf['weather_forecast_method'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/emhass/forecast.py", line 210, in get_weather_forecast
raw_data.set_index(forecast_dates_scrap, inplace=True)
File "/usr/local/lib/python3.11/dist-packages/pandas/core/frame.py", line 5910, in set_index
raise ValueError(
ValueError: Length mismatch: Expected 24 rows, received array of length 48