davidusb-geek / emhass-add-on

The Home Assistant Add-on for EMHASS: Energy Management Optimization for Home Assistant
MIT License
96 stars 29 forks source link

PV power production forecast with method Solar.Forecast service do not work #57

Closed overas closed 9 months ago

overas commented 1 year ago

EMHASS add-on v0.4.2 Home Assistant 2023.10.3

When I use the method=solar.forecast with the parameter "solar_forecast_kwp":5 I get an error. When I use method=scrapper everything is working.

rest_command:
  trigger_tibber_forecast:
    url: http://localhost:5000/action/dayahead-optim
    method: POST
    content_type: "application/json"
    timeout: 300
    payload: >-
      {
      "load_cost_forecast":{{((state_attr('sensor.total_price_toraldasen_32', 'raw_today') | map(attribute='total_with_gridPrice') | list  + state_attr('sensor.total_price_toraldasen_32','raw_today') | map(attribute='total_with_gridPrice') | list))[now().hour:][:24] }},
      "prod_price_forecast":{{((state_attr('sensor.energy_price_toraldasen_32', 'raw_today') | map(attribute='total') | list  + state_attr('sensor.energy_price_toraldasen_32', 'raw_today') | map(attribute='total') | list))[now().hour:][:24]}},
      "def_total_hours":{{states('sensor.list_operating_hours_of_each_deferrable_load')}},
      "solar_forecast_kwp":5
      }
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun emhass (no readiness notification)
s6-rc: info: service legacy-services successfully started
2023-10-21 17:28:36,101 - web_server - INFO - Launching the emhass webserver at: http://0.0.0.0:5000
2023-10-21 17:28:36,101 - web_server - INFO - Home Assistant data fetch will be performed using url: http://supervisor/core/api
2023-10-21 17:28:36,101 - web_server - INFO - The data path is: /share
2023-10-21 17:28:36,102 - web_server - INFO - Using core emhass version: 0.5.1
waitress   INFO  Serving on http://0.0.0.0:5000
2023-10-21 17:28:48,322 - web_server - INFO - Setting up needed data
2023-10-21 17:28:48,355 - web_server - INFO - Retrieving weather forecast data using method = solar.forecast
2023-10-21 17:28:51,886 - 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 89, in set_input_data_dict
    df_weather = fcst.get_weather_forecast(method=optim_conf['weather_forecast_method'])
  File "/usr/local/lib/python3.9/dist-packages/emhass/forecast.py", line 273, in get_weather_forecast
    data_dict = {'ts':list(data_raw['result']['watts'].keys()), 'yhat':list(data_raw['result']['watts'].values())}
TypeError: 'NoneType' object is not subscriptable

emhass_config.txt