Description
Describe the bug
With the DST difficulties many have switched to the forecast.solar method.
This seems to function for one iteration and then fails.
I suspect there may be a rate limit and it would be nice to call the API maybe once per day and cache the results.
I suspect with high frequency MPC that the API end point is called every time and fails.
It would be useful for EMHASS to log the API endpoint it is attempting as well as the results.
[2025-04-06 07:27:52 +1000] [22] [INFO] Retrieving weather forecast data using method = solar.forecast
[2025-04-06 07:27:52 +1000] [22] [WARNING] The free public tier for solar.forecast only provides one day forecasts
[2025-04-06 07:27:52 +1000] [22] [WARNING] Continuing with just the first day of data, the other days are filled with 0.0.
[2025-04-06 07:27:52 +1000] [22] [WARNING] Use the other available methods for delta_forecast_daily > 1
[2025-04-06 07:27:54 +1000] [22] [ERROR] Exception on /action/naive-mpc-optim [POST]
Traceback (most recent call last):
File "/app/.venv/lib/python3.12/site-packages/flask/app.py", line 1511, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/flask/app.py", line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/src/emhass/web_server.py", line 414, in action_call
input_data_dict = set_input_data_dict(
^^^^^^^^^^^^^^^^^^^^
File "/app/src/emhass/command_line.py", line 345, in set_input_data_dict
df_weather = fcst.get_weather_forecast(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/src/emhass/forecast.py", line 484, in get_weather_forecast
"ts": list(data_raw["result"]["watts"].keys()),
~~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: string indices must be integers, not 'str'
To Reproduce
Switch to forecast.solar method, run optimisation twice.
Expected behavior
It would be useful for EMHASS to log the API endpoint it is attempting as well as the results.
I suspect there may be a rate limit and it would be nice to call the API maybe once per day and cache the results.
Caching was supposed to be supported here for this method:
#474
EMHASS installation type
- Add-on