EMHASS: An Energy Management for Home Assistant

Thanks.

Can you show the EMHASS configuration file, the inställningar tab in EMHASS?

Can you also restart EMHASS and show the startup enteries in the logfile?










If you use Frigate the webserver uses tcp port 5000.

Nope. No frigate.
Thx for info

Hi - I am having an awkward problem when doing MPC calls with current values (beta > 0):
Current data for P_Load is always properly working but current data for PV (P_PV) sometimes uses correct data and sometimes just uses 0 despite the underlying sensor being >0.

Below some screen shots showing what I am mean when doing an MPC call every minute (same problem when doing every 15 or 30 minutes) with beta = 1 and alpha = 0.

Power no var Loads = power sensor in W for actual consumption that is fed to Emhass
Load Power Forecast = Published Data from Emhass (P_Load)
Solar Power in Watt = Current PV Production (data coming from Powerwall) that is fed to Emhass
PV Power Forecast = Published Data from Emhass (P_PV)

There is not missing data in ‘Solar Power in Watt’ but Emhass seems to struggle and shows 0 every 30 min (sometimes just for 1 min, sometimes for 30min).

Logs in Emhass look normal. Extract also below.

Any ideas what’s happening? Can I somehow debug?
I have no problem when using alpha = 1 and beta = 0 (i.e. just planned data that I feed with the Emhass call).

Log from around 11am (you can see the change in in P_PV and cost function when the wrong current PV data is used but otherwise no changes):

[2023-02-21 10:59:05,523] INFO in command_line: Setting up needed data
[2023-02-21 10:59:05,531] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 10:59:08,102] INFO in forecast: Retrieving weather forecast data using method = list
[2023-02-21 10:59:08,106] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-21 10:59:08,107] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 10:59:13,605] INFO in web_server:  >> Performing naive MPC optimization...
[2023-02-21 10:59:13,606] INFO in command_line: Performing naive MPC optimization
[2023-02-21 10:59:13,620] INFO in optimization: Perform an iteration of a naive MPC controller
[2023-02-21 10:59:13,850] INFO in optimization: Status: Optimal
[2023-02-21 10:59:13,851] INFO in optimization: Total value of the Cost function = -0.3
[2023-02-21 10:59:25,451] INFO in command_line: Setting up needed data
[2023-02-21 10:59:25,458] INFO in web_server:  >> Publishing data...
[2023-02-21 10:59:25,459] INFO in command_line: Publishing data to HASS instance
[2023-02-21 10:59:25,522] INFO in retrieve_hass: Successfully posted to sensor.p_pv_forecast = 5873.67
[2023-02-21 10:59:25,572] INFO in retrieve_hass: Successfully posted to sensor.p_load_forecast = 844.53
[2023-02-21 10:59:25,614] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable0 = 0.0
[2023-02-21 10:59:25,648] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable1 = 2700.0
[2023-02-21 10:59:25,680] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable2 = 0.0
[2023-02-21 10:59:25,717] INFO in retrieve_hass: Successfully posted to sensor.p_batt_forecast = -2329.15
[2023-02-21 10:59:25,755] INFO in retrieve_hass: Successfully posted to sensor.soc_batt_forecast = 74.26
[2023-02-21 10:59:25,792] INFO in retrieve_hass: Successfully posted to sensor.p_grid_forecast = 0.0
[2023-02-21 10:59:25,836] INFO in retrieve_hass: Successfully posted to sensor.total_cost_fun_value = -0.3
[2023-02-21 11:00:05,522] INFO in command_line: Setting up needed data
[2023-02-21 11:00:05,532] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:00:08,558] INFO in forecast: Retrieving weather forecast data using method = list
[2023-02-21 11:00:08,562] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-21 11:00:08,564] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:00:14,545] INFO in web_server:  >> Performing naive MPC optimization...
[2023-02-21 11:00:14,545] INFO in command_line: Performing naive MPC optimization
[2023-02-21 11:00:14,560] INFO in optimization: Perform an iteration of a naive MPC controller
[2023-02-21 11:00:14,770] INFO in optimization: Status: Optimal
[2023-02-21 11:00:14,771] INFO in optimization: Total value of the Cost function = 1.04
[2023-02-21 11:00:25,451] INFO in command_line: Setting up needed data
[2023-02-21 11:00:25,458] INFO in web_server:  >> Publishing data...
[2023-02-21 11:00:25,458] INFO in command_line: Publishing data to HASS instance
[2023-02-21 11:00:25,521] INFO in retrieve_hass: Successfully posted to sensor.p_pv_forecast = 0.0
[2023-02-21 11:00:25,569] INFO in retrieve_hass: Successfully posted to sensor.p_load_forecast = 851.25
[2023-02-21 11:00:25,626] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable0 = 0.0
[2023-02-21 11:00:25,672] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable1 = 0.0
[2023-02-21 11:00:25,721] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable2 = 0.0
[2023-02-21 11:00:25,759] INFO in retrieve_hass: Successfully posted to sensor.p_batt_forecast = 851.25
[2023-02-21 11:00:25,798] INFO in retrieve_hass: Successfully posted to sensor.soc_batt_forecast = 68.28
[2023-02-21 11:00:25,835] INFO in retrieve_hass: Successfully posted to sensor.p_grid_forecast = 0.0
[2023-02-21 11:00:25,881] INFO in retrieve_hass: Successfully posted to sensor.total_cost_fun_value = 1.04
[2023-02-21 11:01:05,520] INFO in command_line: Setting up needed data
[2023-02-21 11:01:05,528] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:01:08,597] INFO in forecast: Retrieving weather forecast data using method = list
[2023-02-21 11:01:08,601] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-21 11:01:08,604] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:01:14,115] INFO in web_server:  >> Performing naive MPC optimization...
[2023-02-21 11:01:14,116] INFO in command_line: Performing naive MPC optimization
[2023-02-21 11:01:14,130] INFO in optimization: Perform an iteration of a naive MPC controller
[2023-02-21 11:01:14,340] INFO in optimization: Status: Optimal
[2023-02-21 11:01:14,342] INFO in optimization: Total value of the Cost function = 1.06
[2023-02-21 11:01:25,453] INFO in command_line: Setting up needed data
[2023-02-21 11:01:25,460] INFO in web_server:  >> Publishing data...
[2023-02-21 11:01:25,461] INFO in command_line: Publishing data to HASS instance

Same at 11:30 but goes wrong to correct:

[2023-02-21 11:29:05,525] INFO in command_line: Setting up needed data
[2023-02-21 11:29:05,532] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:29:08,244] INFO in forecast: Retrieving weather forecast data using method = list
[2023-02-21 11:29:08,248] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-21 11:29:08,250] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:29:14,301] INFO in web_server:  >> Performing naive MPC optimization...
[2023-02-21 11:29:14,302] INFO in command_line: Performing naive MPC optimization
[2023-02-21 11:29:14,316] INFO in optimization: Perform an iteration of a naive MPC controller
[2023-02-21 11:29:14,521] INFO in optimization: Status: Optimal
[2023-02-21 11:29:14,523] INFO in optimization: Total value of the Cost function = 0.09
[2023-02-21 11:29:25,466] INFO in command_line: Setting up needed data
[2023-02-21 11:29:25,472] INFO in web_server:  >> Publishing data...
[2023-02-21 11:29:25,473] INFO in command_line: Publishing data to HASS instance
[2023-02-21 11:29:25,531] INFO in retrieve_hass: Successfully posted to sensor.p_pv_forecast = 0.0
[2023-02-21 11:29:25,564] INFO in retrieve_hass: Successfully posted to sensor.p_load_forecast = 851.25
[2023-02-21 11:29:25,598] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable0 = 0.0
[2023-02-21 11:29:25,632] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable1 = 0.0
[2023-02-21 11:29:25,674] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable2 = 0.0
[2023-02-21 11:29:25,720] INFO in retrieve_hass: Successfully posted to sensor.p_batt_forecast = 851.25
[2023-02-21 11:29:25,762] INFO in retrieve_hass: Successfully posted to sensor.soc_batt_forecast = 83.28
[2023-02-21 11:29:25,814] INFO in retrieve_hass: Successfully posted to sensor.p_grid_forecast = 0.0
[2023-02-21 11:29:25,860] INFO in retrieve_hass: Successfully posted to sensor.total_cost_fun_value = 0.09
[2023-02-21 11:30:05,532] INFO in command_line: Setting up needed data
[2023-02-21 11:30:05,539] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:30:08,112] INFO in forecast: Retrieving weather forecast data using method = list
[2023-02-21 11:30:08,118] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-21 11:30:08,120] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:30:14,687] INFO in web_server:  >> Performing naive MPC optimization...
[2023-02-21 11:30:14,688] INFO in command_line: Performing naive MPC optimization
[2023-02-21 11:30:14,703] INFO in optimization: Perform an iteration of a naive MPC controller
[2023-02-21 11:30:14,896] INFO in optimization: Status: Optimal
[2023-02-21 11:30:14,898] INFO in optimization: Total value of the Cost function = 0.39
[2023-02-21 11:30:25,458] INFO in command_line: Setting up needed data
[2023-02-21 11:30:25,463] INFO in web_server:  >> Publishing data...
[2023-02-21 11:30:25,463] INFO in command_line: Publishing data to HASS instance
[2023-02-21 11:30:25,535] INFO in retrieve_hass: Successfully posted to sensor.p_pv_forecast = 0.0
[2023-02-21 11:30:25,576] INFO in retrieve_hass: Successfully posted to sensor.p_load_forecast = 851.25
[2023-02-21 11:30:25,638] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable0 = 0.0
[2023-02-21 11:30:25,685] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable1 = 0.0
[2023-02-21 11:30:25,753] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable2 = 0.0
[2023-02-21 11:30:25,791] INFO in retrieve_hass: Successfully posted to sensor.p_batt_forecast = 851.25
[2023-02-21 11:30:25,831] INFO in retrieve_hass: Successfully posted to sensor.soc_batt_forecast = 83.28
[2023-02-21 11:30:25,870] INFO in retrieve_hass: Successfully posted to sensor.p_grid_forecast = 0.0
[2023-02-21 11:30:25,916] INFO in retrieve_hass: Successfully posted to sensor.total_cost_fun_value = 0.39
[2023-02-21 11:31:05,526] INFO in command_line: Setting up needed data
[2023-02-21 11:31:05,534] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:31:07,968] INFO in forecast: Retrieving weather forecast data using method = list
[2023-02-21 11:31:07,974] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-21 11:31:07,976] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2023-02-21 11:31:14,114] INFO in web_server:  >> Performing naive MPC optimization...
[2023-02-21 11:31:14,115] INFO in command_line: Performing naive MPC optimization
[2023-02-21 11:31:14,129] INFO in optimization: Perform an iteration of a naive MPC controller
[2023-02-21 11:31:14,313] INFO in optimization: Status: Optimal
[2023-02-21 11:31:14,314] INFO in optimization: Total value of the Cost function = 0.81
[2023-02-21 11:31:25,454] INFO in command_line: Setting up needed data
[2023-02-21 11:31:25,463] INFO in web_server:  >> Publishing data...
[2023-02-21 11:31:25,463] INFO in command_line: Publishing data to HASS instance
[2023-02-21 11:31:25,527] INFO in retrieve_hass: Successfully posted to sensor.p_pv_forecast = 11685.0
[2023-02-21 11:31:25,593] INFO in retrieve_hass: Successfully posted to sensor.p_load_forecast = 1136.35
[2023-02-21 11:31:25,665] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable0 = 0.0
[2023-02-21 11:31:25,715] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable1 = 0.0
[2023-02-21 11:31:25,761] INFO in retrieve_hass: Successfully posted to sensor.p_deferrable2 = 0.0
[2023-02-21 11:31:25,801] INFO in retrieve_hass: Successfully posted to sensor.p_batt_forecast = -4145.18
[2023-02-21 11:31:25,843] INFO in retrieve_hass: Successfully posted to sensor.soc_batt_forecast = 93.57
[2023-02-21 11:31:25,880] INFO in retrieve_hass: Successfully posted to sensor.p_grid_forecast = -6403.47
[2023-02-21 11:31:25,927] INFO in retrieve_hass: Successfully posted to sensor.total_cost_fun_value = 0.81

Data last 3 hours:

Data last 45min:

Thanks

I have recently been seeing something similar with beta=1, initially it was for just a minute, but then I started seeing it spread out to 30 minutes as you are reporting.

My theory is with beta=1 is that it is looking at the values for 24 hours past and if there is a glitch = zero that gets amplified and repeated over and over.

I now running with alpha=1,beta=0 and supplying the now values directly on the command line, I now see agreement between EMHASS forecasts correct to the W every minute.

I also had to supply the current/now load forecast on the command line and created a FIFO buffer to track the past 24 hrs load_no_vars.

          \"pv_power_forecast\":{{[states('sensor.APF_Generation_Entity')|int(0)] 
           + state_attr('sensor.solcast_forecast_today', 'detailedForecast')|selectattr('period_start','gt',utcnow())
             | map(attribute='pv_estimate')|map('multiply',2000)|map('int')|list 
           + state_attr('sensor.solcast_forecast_tomorrow', 'detailedForecast')|selectattr('period_start','gt',utcnow())
             | map(attribute='pv_estimate')|map('multiply',2000)|map('int')|list
          }},

          \"load_power_forecast\":{{
          [states('sensor.power_load_no_var_loads')|int] +(states('input_text.fi_fo_buffer').split(', ')|map('multiply',1000)|map('int')|list)[1:]
          }},

Understood and makes sense. Would you mind sharing your FIFO buffer code? Still wondering on implementation. Thanks a lot!

No problem.

I store input_text.fi_fo_buffer as a list of 48x kW values for each 30 minute time slot. I chose kW as it would fit inside the 255 char limit.

Every 30 minutes I reset the input_text.fi_fo_buffer with elements [1:48] + the current value of power_load_no_var_loads. It might be more accurate to use the rolling 30 minute value, but I haven’t implemented that.

alias: read_sensor_data
description: ""
trigger:
  - platform: time_pattern
    minutes: /30
condition: []
action:
  - service: input_text.set_value
    target:
      entity_id: input_text.fi_fo_buffer
    data:
      value: >
        {{ (states('input_text.fi_fo_buffer').split(', ')[1:48]  + [
        (states('sensor.power_load_no_var_loads')|float(0)/1000)|round(1)])
        |join(', ') }}
mode: single

I have setup the fifo using helpers:

and you need to prefill with 48 values, one neat benefit is you can change the prefil at any time, if for example your forecast household load changes.

trying to understand the soc of battery and not understanding why its moving up and down all the time?


I think i figured it out. It had a parameter with all solar to grid activated. But I have another question as well. 13:00 are there lots of solar power coming in and the forcast soc is 90. If i run an automation and set the soc to 90 on my inverters it will charge from the grid if there is no solar. Not always this is profitable. Or do you do this in another way?

So in that same automation or in a new one, stop the battery charging when it arrives to SOCmax. I don’t see the problem since you said that you have lots of PV in that time slot. Or simpler set the automation to directly forbidden charging your battery from the grid. EHMASS is just giving you an optimal SOC reference to follow, but you need to fine control that using automations

Yes. Only that if its set to 90 the battery will not compensate if there is not enough solar for a period. Yes i will find a way todo this :blush:

What is the difference between cost. Self consumption and profit?

https://emhass.readthedocs.io/en/latest/lpems.html#cost-functions

1 Like

Hey

Back from Austria.
Reinstalled emhass now I can reach the first page in my browser. But, when clicking one of the options nothing happens.

I couldn’t find my solar module so I picked a longi panel.
My panel: Denim U - Mono 405 All Black Half Cut

Attaching the log
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment
[2023-02-26 13:36:27,434] INFO in command_line: Setting up needed data
[2023-02-26 13:36:27,447] INFO in forecast: Retrieving weather forecast data using method = scrapper
[2023-02-26 13:36:30,780] ERROR in app: Exception on /action/dayahead-optim [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/pandas/core/indexes/base.py”, line 3621, in get_loc
return self._engine.get_loc(casted_key)
File “pandas/_libs/index.pyx”, line 136, in pandas._libs.index.IndexEngine.get_loc
File “pandas/_libs/index.pyx”, line 163, in pandas._libs.index.IndexEngine.get_loc
File “pandas/_libs/hashtable_class_helper.pxi”, line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
File “pandas/_libs/hashtable_class_helper.pxi”, line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: ‘LONGi_Green_Energy_Technology_Co.__Ltd.LR6-72HBD-385M
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 135, 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 82, in set_input_data_dict
P_PV_forecast = fcst.get_power_from_weather(df_weather)
File “/usr/local/lib/python3.9/dist-packages/emhass/forecast.py”, line 379, in get_power_from_weather
module = cec_modules[self.plant_conf[‘module_model’][i]]
File “/usr/local/lib/python3.9/dist-packages/pandas/core/frame.py”, line 3505, in getitem
indexer = self.columns.get_loc(key)
File “/usr/local/lib/python3.9/dist-packages/pandas/core/indexes/base.py”, line 3623, in get_loc
raise KeyError(key) from err
KeyError: ‘LONGi_Green_Energy_Technology_Co.__Ltd.LR6-72HBD-385M
[2023-02-26 13:37:19,091] INFO in command_line: Setting up needed data
[2023-02-26 13:37:19,148] INFO in retrieve_hass: Retrieve hass get data method initiated…
[2023-02-26 13:37:32,004] INFO in web_server: >> Performing perfect optimization…
[2023-02-26 13:37:32,005] INFO in command_line: Performing perfect forecast optimization
[2023-02-26 13:37:32,025] INFO in optimization: Perform optimization for perfect forecast scenario
[2023-02-26 13:37:32,028] INFO in optimization: Solving for day: 24-2-2023
[2023-02-26 13:38:21,735] INFO in command_line: Setting up needed data
[2023-02-26 13:38:21,767] INFO in web_server: >> Publishing data…
[2023-02-26 13:38:21,768] INFO in command_line: Publishing data to HASS instance
[2023-02-26 13:38:21,768] ERROR in command_line: File not found error, run an optimization task first.
[2023-02-26 13:38:21,770] ERROR in app: Exception on /action/publish-data [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 139, in action_call
_ = publish_data(input_data_dict, app.logger)
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment
[2023-02-26 13:40:00,582] INFO in command_line: Setting up needed data
[2023-02-26 13:40:00,593] INFO in web_server: >> Publishing data…
[2023-02-26 13:40:00,594] INFO in command_line: Publishing data to HASS instance
[2023-02-26 13:40:00,599] ERROR in command_line: File not found error, run an optimization task first.
[2023-02-26 13:40:00,601] ERROR in app: Exception on /action/publish-data [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 139, in action_call
_ = publish_data(input_data_dict, app.logger)
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment
[2023-02-26 13:45:00,977] INFO in command_line: Setting up needed data
[2023-02-26 13:45:01,271] INFO in web_server: >> Publishing data…
[2023-02-26 13:45:01,273] INFO in command_line: Publishing data to HASS instance
[2023-02-26 13:45:01,274] ERROR in command_line: File not found error, run an optimization task first.
[2023-02-26 13:45:01,275] ERROR in app: Exception on /action/publish-data [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 139, in action_call
_ = publish_data(input_data_dict, app.logger)
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment

In the string of your module you have to replace all the special characters in the model name by ‘_’.

Thx. Do you know if denim exists in cec list?

Changed the namn
And now getting this

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-02-26 22:14:45,640] INFO in web_server: Launching the emhass webserver at: http://0.0.0.0:5000
[2023-02-26 22:14:45,641] INFO in web_server: Home Assistant data fetch will be performed using url: http://supervisor/core/api
[2023-02-26 22:14:45,641] INFO in web_server: The data path is: /share
[2023-02-26 22:14:45,660] INFO in web_server: Using core emhass version: 0.3.36
[2023-02-26 22:15:00,594] INFO in command_line: Setting up needed data
[2023-02-26 22:15:00,846] INFO in web_server: >> Publishing data…
[2023-02-26 22:15:00,846] INFO in command_line: Publishing data to HASS instance
[2023-02-26 22:15:00,849] ERROR in command_line: File not found error, run an optimization task first.
[2023-02-26 22:15:00,850] ERROR in app: Exception on /action/publish-data [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 139, in action_call
_ = publish_data(input_data_dict, app.logger)
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment
[2023-02-26 22:16:04,564] INFO in command_line: Setting up needed data
[2023-02-26 22:16:04,592] INFO in retrieve_hass: Retrieve hass get data method initiated…
[2023-02-26 22:16:09,077] INFO in command_line: Setting up needed data
[2023-02-26 22:16:09,085] INFO in web_server: >> Publishing data…
[2023-02-26 22:16:09,128] INFO in command_line: Publishing data to HASS instance
[2023-02-26 22:16:09,136] ERROR in command_line: File not found error, run an optimization task first.
[2023-02-26 22:16:09,154] ERROR in app: Exception on /action/publish-data [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 139, in action_call
_ = publish_data(input_data_dict, app.logger)
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment
[2023-02-26 22:16:13,639] INFO in web_server: EMHASS server online, serving index.html…
[2023-02-26 22:16:13,737] WARNING in web_server: The data container dictionary is empty… Please launch an optimization task
[2023-02-26 22:16:15,714] INFO in web_server: >> Performing perfect optimization…
[2023-02-26 22:16:15,715] INFO in command_line: Performing perfect forecast optimization
[2023-02-26 22:16:15,728] INFO in optimization: Perform optimization for perfect forecast scenario
[2023-02-26 22:16:15,733] INFO in optimization: Solving for day: 24-2-2023

If you have the optimization results graphs then everything is ok. Those errors werer thrown because you tried to publish data before performing the optimization task, so there was nothing to publish.

Ok. But I don’t see any graphs

Hi
Can someone help me?

I can reache the emhass website but it won’t display any graphs?

Latest error in emhass log file

method = scrapper
[2023-02-28 10:24:26,237] INFO in command_line: Setting up needed data
[2023-02-28 10:24:26,245] INFO in web_server: >> Publishing data…
[2023-02-28 10:24:26,246] INFO in command_line: Publishing data to HASS instance
[2023-02-28 10:24:26,246] ERROR in command_line: File not found error, run an optimization task first.
[2023-02-28 10:24:26,247] ERROR in app: Exception on /action/publish-data [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 139, in action_call
_ = publish_data(input_data_dict, app.logger)
File “/usr/local/lib/python3.9/dist-packages/emhass/command_line.py”, line 290, in publish_data
idx_closest = opt_res_latest.index.get_indexer([now_precise], method=‘nearest’)[0]
UnboundLocalError: local variable ‘opt_res_latest’ referenced before assignment
[2023-02-28 10:24:27,386] INFO in forecast: Retrieving data from hass for load forecast using method = naive
[2023-02-28 10:24:27,416] INFO in retrieve_hass: Retrieve hass get data method initiated…
[2023-02-28 10:24:27,486] ERROR in retrieve_hass: The retrieved JSON is empty, check that correct day or variable names are passed
[2023-02-28 10:24:27,486] ERROR in retrieve_hass: 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-02-28 10:24:27,488] ERROR in app: Exception on /action/dayahead-optim [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.9/dist-packages/flask/app.py”, line 1796, 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 135, 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 83, 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 538, in get_load_forecast
rh.get_data(days_list, var_list)
File “/usr/local/lib/python3.9/dist-packages/emhass/retrieve_hass.py”, line 144, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
UnboundLocalError: local variable ‘df_day’ referenced before assignment