@davidusb I’ve had to delete my recorder database and restart HA to create a new one. After doing this dayahead returns the following errors:
2023-11-05 20:08:45,574 - web_server - INFO - Setting up needed data
2023-11-05 20:08:45,576 - web_server - INFO - Retrieving weather forecast data using method = list
2023-11-05 20:08:45,577 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2023-11-05 20:08:45,577 - web_server - INFO - Retrieve hass get data method initiated...
2023-11-05 20:08:45,586 - web_server - ERROR - The retrieved JSON is empty, check that correct day or variable names are passed
2023-11-05 20:08:45,586 - web_server - ERROR - Either the names of the passed variables are not correct or days_to_retrieve is larger than the recorded history of your sensor (check your recorder settings)
2023-11-05 20:08:45,586 - web_server - ERROR - Exception on /action/dayahead-optim [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1455, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 869, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 867, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 852, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/dist-packages/emhass/web_server.py", line 179, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 91, in set_input_data_dict
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
File "/usr/local/lib/python3.9/dist-packages/emhass/forecast.py", line 585, in get_load_forecast
rh.get_data(days_list, var_list)
File "/usr/local/lib/python3.9/dist-packages/emhass/retrieve_hass.py", line 147, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
UnboundLocalError: local variable 'df_day' referenced before assignment
MPC doesn’t work either.
I’m not sure how to fix this? Can you help?
My curl template is:
{
"load_cost_forecast": {{
([states('sensor.cecil_st_general_price')|float(0)] +
state_attr('sensor.cecil_st_general_forecast', 'forecasts') |map(attribute='per_kwh')|list)
| tojson
}},
"prod_price_forecast": {{
([states('sensor.cecil_st_feed_in_price')|float(0)] +
(state_attr('sensor.cecil_st_feed_in_forecast', 'forecasts')|map(attribute='per_kwh')|list))
| tojson
}},
"pv_power_forecast": {{
([states('sensor.sonnenbatterie_84324_production_w')|int(0)] +
state_attr('sensor.solcast_pv_forecast_forecast_today', 'detailedForecast')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',1000)|map('int')|list +
state_attr('sensor.solcast_pv_forecast_forecast_tomorrow', 'detailedForecast')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',1000)|map('int')|list
)| tojson
}},
"num_def_loads": 2,
"def_total_hours": [3,0],
"P_deferrable_nom": [1300, 7360],
"treat_def_as_semi_cont": [1, 0]
}
And this is the result from that template:
{
"load_cost_forecast": [0.18, 0.17, 0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.15, 0.16, 0.15, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.16, 0.16, 0.16, 0.13, 0.13, 0.13, 0.12, 0.1, 0.12, 0.1, 0.09, 0.08, 0.07, 0.07, 0.07, 0.07, 0.35, 0.36, 0.36, 0.36, 0.38, 0.38, 0.39, 0.4, 0.41, 0.43, 0.45, 0.45, 0.19],
"prod_price_forecast": [0.08, 0.08, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.06, 0.06, 0.06, 0.04, 0.04, 0.04, 0.03, 0.01, 0.0, -0.01, -0.02, -0.03, -0.04, -0.04, -0.04, -0.04, 0.26, 0.28, 0.28, 0.28, 0.29, 0.29, 0.3, 0.31, 0.32, 0.34, 0.36, 0.36, 0.09],
"pv_power_forecast": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 147, 493, 796, 1061, 1254, 1443, 1613, 1771, 1946, 2114, 2211, 2286, 2355, 2365, 2298, 2163, 1978, 1849, 1727, 1465, 1137, 903, 621, 313, 82, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"num_def_loads": 2,
"def_total_hours": [3,0],
"P_deferrable_nom": [1300, 7360],
"treat_def_as_semi_cont": [1, 0]
}
Thanks in advance.