EMHASS add-on: An energy management optimization add-on for Home Assistant OS and supervised

Hello everyone!

This is the first release of this add-on for Home Assistant!!!

The add-on repository and installation instructions are here: https://github.com/davidusb-geek/emhass-add-on

This add-on implements the EMHASS module for systems using Home Assistant OS or Home Assistant Supervised.

EMHASS is a Python module for Energy Management Optimization in Home Assistant.
You can check the project source code here: https://github.com/davidusb-geek/emhass

Feel free to test this add-on as you will and give me some feedback.
We can use this topic to exchange any feedback or you can also directly open an issue on the add-on repository: https://github.com/davidusb-geek/emhass-add-on/issues

The thread for the EMHASS Python module: https://community.home-assistant.io/t/emhass-an-energy-management-for-home-assistant

Cheers!!!

6 Likes

This add-on v0.1.19:

I’m having some challenges getting the addon to function.

Using the default config I have setup two sensor values for production and load_novars.

I am running on an odroid n2+.

But when I try to run the day ahead routine I get the following errors in the logs.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
 * Serving Flask app 'app_server' (lazy loading)
 * Environment: development
 * Debug mode: off
 * Running on all addresses (0.0.0.0)
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://127.0.0.1:5000
 * Running on http://172.30.33.1:5000 (Press CTRL+C to quit)
[2022-04-16 08:15:27,386] 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 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/src/app_server.py", line 150, in action_call
    opt_res = dayahead_forecast_optim(input_data_dict, app.logger)
  File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 127, in dayahead_forecast_optim
    opt_res_dayahead = input_data_dict['opt'].perform_dayahead_forecast_optim(
  File "/usr/local/lib/python3.9/dist-packages/emhass/optimization.py", line 411, in perform_dayahead_forecast_optim
    self.opt_res = self.perform_optimization(P_load, P_PV.values.ravel(),
  File "/usr/local/lib/python3.9/dist-packages/emhass/optimization.py", line 301, in perform_optimization
    opt_model.solve(PULP_CBC_CMD(msg=0))
  File "/usr/local/lib/python3.9/dist-packages/pulp/pulp.py", line 1913, in solve
    status = solver.actualSolve(self, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/pulp/apis/coin_api.py", line 137, in actualSolve
    return self.solve_CBC(lp, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/pulp/apis/coin_api.py", line 194, in solve_CBC
    cbc = subprocess.Popen(args, stdout=pipe, stderr=pipe, stdin=devnull)
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/usr/local/lib/python3.9/dist-packages/pulp/apis/../solverdir/cbc/linux/64/cbc'
192.168.86.50 - - [16/Apr/2022 08:15:27] "POST /action/dayahead-optim HTTP/1.1" 500 -
type or paste code here

Oh you’re having problems with the default linear programming solver CBC. This is definitely related to the ondroid n2+ architecture. There is certainly a solution for this. Could you please tell which architecture is that? Do:

uname - a

on a command window

Also as it is an Oserror which os are you using?
Try any of these:

cat /etc/os-release
lsb_release -a
hostnamectl

Thanks.

aarch64 on Ubuntu

Hi there, ok so I modified the core EMHASS Python module for better handling of this type of error and falling back to a probable suitable solver for your architecture.
In your case I hope that a new solver install will fix the issue. I’m not able to test this directly as I don’t have a arm64 device. However I did successfully tested the new solver glpk install inside the add-on container.
So, update to the latest release of the Add-on v0.1.21 and please tell me how it went.

Thanks for the update, but 0.1.21 will not install :frowning:

Can you assist me setup a dev environment here so I can test locally?

Oh man those alpine Linux are a pain. The add-on install just fine on my dev env in Ubuntu 20.04.
If you help me solve this it will be really helpful as this means that the add-on will fail on any Raspberry pi4 64 bits, ondroid n2+, or similar architecture out there. We could get some insight of the installation error from your supervisor logs. Check the supervisor logs at the moment when the add-on install fails and post them here. On my side I will try to build the docker images myself so that the user just download them and run them. I guess that will solve any install issue.

In the meantime of course you can test EMHASS locally using just the core EMHASS python module. Go to the github and follow the installation instructions, they are fairly simple using a python virtual environment. You will just need a pc running Linux. A windows pc with conda installed can also be used. You will need to create a long lived access token from your Home Assistant profile page. If you are stuck at any moment with the installation process I can assist you with no problem.

No problem, I have lots of Linux boxes and no Windows so certainly can assist.

Looks like there might be an issue with the pulptest and cbc module inside the emhass environment, works fine outside emhass environment.

I’ll get some logs shortly.

(emhassenv) [email protected]:~/emhassenv$ pulptest 
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss         Test that logic put in place for deprecation handling of indexs works
.        Testing 'indexs' param continues to work for LpVariable.dicts
         Testing 'indexs' param continues to work for LpVariable.matrix
.        Testing 'indices' argument works in LpVariable.dicts
         Testing 'indices' param continues to work for LpVariable.matrix
.        Testing invalid status
.        Testing continuous LP solution - export dict
.        Testing export dict for LP
.        Testing export dict MIP
.        Testing maximize continuous LP solution
.        Testing continuous LP solution - export JSON
.        Testing continuous LP solution - export solver dict
.        Testing continuous LP solution - export solver JSON
..       Testing reading MPS files - binary variable, no constraint names
.        Testing reading MPS files - integer variable
.        Testing reading MPS files - maximize
..       Testing invalid var names
.        Testing logPath argument
.        Testing makeDict general behavior
.        Testing makeDict default value behavior
.        Testing measuring optimization time
.        Testing the availability of the function pulpTestAll
.        Testing zero subtraction
.        Testing inconsistent lp solution
.        Testing continuous LP solution
.        Testing maximize continuous LP solution
.        Testing unbounded continuous LP solution
.        Testing Long Names
.        Testing repeated Names
.        Testing zero constraint
.        Testing zero objective
.        Testing LpVariable (not LpAffineExpression) objective
.        Testing Long lines in LP
.        Testing LpAffineExpression divide
.        Testing MIP solution
.        Testing MIP solution with floats in objective
.        Testing Initial value in MIP solution
.        Testing fixing value in MIP solution
.        Testing MIP relaxation
.        Testing feasibility problem (no objective)
.        Testing an infeasible problem
.        Testing an integer infeasible problem
.        Testing another integer infeasible problem
.        Testing column based modelling
.....    Testing fractional constraints
.        Testing elastic constraints (no change)
.        Testing elastic constraints (freebound)
.        Testing elastic constraints (penalty unchanged)
.        Testing elastic constraints (penalty unbounded)
.        Testing timeLimit argument
...ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss  Test that logic put in place for deprecation handling of indexs works
.        Testing 'indexs' param continues to work for LpVariable.dicts
         Testing 'indexs' param continues to work for LpVariable.matrix
.        Testing 'indices' argument works in LpVariable.dicts
         Testing 'indices' param continues to work for LpVariable.matrix
.        Testing invalid status
.        Testing continuous LP solution - export dict
E        Testing export dict for LP
E        Testing export dict MIP
E        Testing maximize continuous LP solution
E        Testing continuous LP solution - export JSON
E        Testing continuous LP solution - export solver dict
E        Testing continuous LP solution - export solver JSON
E.       Testing reading MPS files - binary variable, no constraint names
.        Testing reading MPS files - integer variable
.        Testing reading MPS files - maximize
.E       Testing invalid var names
E        Testing logPath argument
E        Testing makeDict general behavior
.        Testing makeDict default value behavior
.        Testing measuring optimization time
E        Testing the availability of the function pulpTestAll
.        Testing zero subtraction
.        Testing inconsistent lp solution
E        Testing continuous LP solution
E        Testing maximize continuous LP solution
E        Testing unbounded continuous LP solution
E        Testing Long Names
E        Testing repeated Names
E        Testing zero constraint
E        Testing zero objective
E        Testing LpVariable (not LpAffineExpression) objective
E        Testing Long lines in LP
E        Testing LpAffineExpression divide
E        Testing MIP solution
E        Testing MIP solution with floats in objective
E        Testing Initial value in MIP solution
E        Testing fixing value in MIP solution
E        Testing MIP relaxation
E        Testing feasibility problem (no objective)
E        Testing an infeasible problem
E        Testing an integer infeasible problem
E        Testing another integer infeasible problem
E        Testing column based modelling
E.       Testing dual variables and slacks reporting
EE.      Testing fractional constraints
E        Testing elastic constraints (no change)
E        Testing elastic constraints (freebound)
E        Testing elastic constraints (penalty unchanged)
E        Testing elastic constraints (penalty unbounded)
E        Testing timeLimit argument
E.Essssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
======================================================================
ERROR: test_export_dict_LP (pulp.tests.test_pulp.PULP_CBC_CMDTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mark/emhassenv/lib/python3.8/site-packages/pulp/tests/test_pulp.py", line 784, in test_export_dict_LP
    pulpTestCheck(
  File "/home/mark/emhassenv/lib/python3.8/site-packages/pulp/tests/test_pulp.py", line 1358, in pulpTestCheck
    status = prob.solve(solver, **kwargs)
  File "/home/mark/emhassenv/lib/python3.8/site-packages/pulp/pulp.py", line 1913, in solve
    status = solver.actualSolve(self, **kwargs)
  File "/home/mark/emhassenv/lib/python3.8/site-packages/pulp/apis/coin_api.py", line 137, in actualSolve
    return self.solve_CBC(lp, **kwargs)
  File "/home/mark/emhassenv/lib/python3.8/site-packages/pulp/apis/coin_api.py", line 194, in solve_CBC
    cbc = subprocess.Popen(args, stdout=pipe, stderr=pipe, stdin=devnull)
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/mark/emhassenv/lib/python3.8/site-packages/pulp/apis/../solverdir/cbc/linux/64/cbc'

A lot of similar error messages from the supervisor logs during an install;

...
	 Testing elastic constraints (no change)
	 Testing elastic constraints (freebound)
	 Testing elastic constraints (penalty unchanged)
	 Testing elastic constraints (penalty unbounded)
	 Testing timeLimit argument
Traceback (most recent call last):
  File "/usr/local/bin/pulptest", line 8, in <module>

    sys.exit(pulpTestAll())
  File "/usr/local/lib/python3.9/dist-packages/pulp/tests/run_tests.py", line 12, in pulpTestAll

    raise pulp.PulpError("Tests Failed")

pulp.constants.PulpError: Tests Failed

Removing intermediate container 89dedcab018b
Apr 17 22:38:16 odroid hassio-supervisor[3944]: ======================================================================
Apr 17 22:38:16 odroid hassio-supervisor[3944]: #033[0m
Apr 17 22:38:16 odroid hassio-supervisor[3944]: #033[91mERROR: test_export_dict_LP (pulp.tests.test_pulp.PULP_CBC_CMDTest)
Apr 17 22:38:16 odroid hassio-supervisor[3944]: ----------------------------------------------------------------------
Apr 17 22:38:16 odroid hassio-supervisor[3944]: Traceback (most recent call last):
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/local/lib/python3.9/dist-packages/pulp/tests/test_pulp.py", line 784, in test_export_dict_LP
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     pulpTestCheck(
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/local/lib/python3.9/dist-packages/pulp/tests/test_pulp.py", line 1358, in pulpTestCheck
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     status = prob.solve(solver, **kwargs)
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/local/lib/python3.9/dist-packages/pulp/pulp.py", line 1913, in solve
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     status = solver.actualSolve(self, **kwargs)
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/local/lib/python3.9/dist-packages/pulp/apis/coin_api.py", line 137, in actualSolve
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     return self.solve_CBC(lp, **kwargs)
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/local/lib/python3.9/dist-packages/pulp/apis/coin_api.py", line 194, in solve_CBC
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     cbc = subprocess.Popen(args, stdout=pipe, stderr=pipe, stdin=devnull)
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     self._execute_child(args, executable, preexec_fn, close_fds,
Apr 17 22:38:16 odroid hassio-supervisor[3944]:   File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
Apr 17 22:38:16 odroid hassio-supervisor[3944]:     raise child_exception_type(errno_num, err_msg, err_filename)
Apr 17 22:38:16 odroid hassio-supervisor[3944]: OSError: [Errno 8] Exec format error: '/usr/local/lib/python3.9/dist-packages/pulp/apis/../solverdir/cbc/linux/64/cbc'
Apr 17 22:38:16 odroid hassio-supervisor[3944]: #033[0m
Apr 17 22:38:16 odroid hassio-supervisor[3944]: #033[91m======================================================================

Ok. Could you please try it now, I’ve updated to v0.1.22. Let’s just shunt the pulp tests and see if the solver error can be catched and then the package will be able to use the glpk solver as a fallback.

Are you able to run the optimization? After editing the config_emhass.yaml file from inside the emhassenv you can do:

emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml' --costfun 'profit'

As pulptests is failing you may try to install another solver manually.
The glpk solver can be installed using:

sudo apt-get install glpk-utils

Tell me how this goes

Thanks, 0.1.22 is loading and I can run the dayahead optimisation.

I shall now customise the settings to see if I can get this relevant to my local setup.

[email protected]:~$ curl -i -H "Content-Type: application/json" -X POST -d '{}' http://localhost:5000/action/dayahead-optim
HTTP/1.1 201 CREATED
Server: Werkzeug/2.1.1 Python/3.9.2
Date: Sun, 17 Apr 2022 20:45:04 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 45

EMHASS >> Action dayahead-optim received... 

Fallback options seem to be working:

Apr 18 06:57:37 odroid 50762d4c4877[3040]: [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [s6-init] ensuring user provided files have correct perms...exited 0.
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [fix-attrs.d] applying ownership & permissions fixes...
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [fix-attrs.d] done.
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [cont-init.d] executing container initialization scripts...
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [cont-init.d] done.
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [services.d] starting services
Apr 18 06:57:37 odroid 50762d4c4877[3040]: [services.d] done.
Apr 18 06:57:40 odroid 50762d4c4877[3040]:  * Serving Flask app 'app_server' (lazy loading)
Apr 18 06:57:40 odroid 50762d4c4877[3040]:  * Environment: development
Apr 18 06:57:40 odroid 50762d4c4877[3040]:  * Debug mode: off
Apr 18 06:57:40 odroid 50762d4c4877[3040]:  * Running on all addresses (0.0.0.0)
Apr 18 06:57:40 odroid 50762d4c4877[3040]:    WARNING: This is a development server. Do not use it in a production deployment.
Apr 18 06:57:40 odroid 50762d4c4877[3040]:  * Running on http://127.0.0.1:5000
Apr 18 06:57:40 odroid 50762d4c4877[3040]:  * Running on http://172.30.33.4:5000 (Press CTRL+C to quit)
Apr 18 06:58:25 odroid 50762d4c4877[3040]: [2022-04-18 06:58:25,055] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
Apr 18 06:58:25 odroid 50762d4c4877[3040]: [2022-04-18 06:58:25,100] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
Apr 18 06:58:27 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:58:27] "GET / HTTP/1.1" 200 -
Apr 18 06:58:28 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:58:28] "#033[36mGET /static/style.css HTTP/1.1#033[0m" 304 -
Apr 18 06:58:35 odroid 50762d4c4877[3040]: [2022-04-18 06:58:35,888] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
Apr 18 06:58:35 odroid 50762d4c4877[3040]: [2022-04-18 06:58:35,919] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
Apr 18 06:58:53 odroid 50762d4c4877[3040]: [2022-04-18 06:58:53,243] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
Apr 18 06:58:53 odroid 50762d4c4877[3040]: [2022-04-18 06:58:53,276] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
Apr 18 06:58:55 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:58:55] "#033[35m#033[1mPOST /action/dayahead-optim HTTP/1.1#033[0m" 201 -
Apr 18 06:59:05 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:59:05] "#033[35m#033[1mPOST /action/dayahead-optim HTTP/1.1#033[0m" 201 -
Apr 18 06:59:06 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:59:06] "GET / HTTP/1.1" 200 -
Apr 18 06:59:06 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:59:06] "#033[36mGET /static/style.css HTTP/1.1#033[0m" 304 -
Apr 18 06:59:15 odroid 50762d4c4877[3040]: 192.168.86.50 - - [18/Apr/2022 06:59:15] "#033[35m#033[1mPOST /action/dayahead-optim HTTP/1.1#033[0m" 201 -

Looks like some issues now with the publish:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
 * Serving Flask app 'app_server' (lazy loading)
 * Environment: development
 * Debug mode: off
 * Running on all addresses (0.0.0.0)
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://127.0.0.1:5000
 * Running on http://172.30.33.4:5000 (Press CTRL+C to quit)
[2022-04-18 06:58:25,055] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
[2022-04-18 06:58:25,100] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
192.168.86.50 - - [18/Apr/2022 06:58:27] "GET / HTTP/1.1" 200 -
192.168.86.50 - - [18/Apr/2022 06:58:28] "GET /static/style.css HTTP/1.1" 304 -
[2022-04-18 06:58:35,888] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
[2022-04-18 06:58:35,919] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
[2022-04-18 06:58:53,243] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
[2022-04-18 06:58:53,276] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
192.168.86.50 - - [18/Apr/2022 06:58:55] "POST /action/dayahead-optim HTTP/1.1" 201 -
192.168.86.50 - - [18/Apr/2022 06:59:05] "POST /action/dayahead-optim HTTP/1.1" 201 -
192.168.86.50 - - [18/Apr/2022 06:59:06] "GET / HTTP/1.1" 200 -
192.168.86.50 - - [18/Apr/2022 06:59:06] "GET /static/style.css HTTP/1.1" 304 -
192.168.86.50 - - [18/Apr/2022 06:59:15] "POST /action/dayahead-optim HTTP/1.1" 201 -
[2022-04-18 07:01:55,969] ERROR in command_line: File not found error, run the dayahead_forecast_optim first.
[2022-04-18 07:01:55,969] 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 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/src/app_server.py", line 146, in action_call
    _ = publish_data(input_data_dict, app.logger)
  File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 162, in publish_data
    idx_closest = opt_res_dayahead.index.get_loc(now_precise, method='ffill')
UnboundLocalError: local variable 'opt_res_dayahead' referenced before assignment
192.168.86.50 - - [18/Apr/2022 07:01:55] "POST /action/publish-data HTTP/1.1" 500 -
192.168.86.50 - - [18/Apr/2022 07:02:55] "GET / HTTP/1.1" 200 -
192.168.86.50 - - [18/Apr/2022 07:02:55] "GET /static/style.css HTTP/1.1" 304 -
[2022-04-18 08:34:56,133] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1526, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1545, in finalize_request
    response = self.make_response(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1701, in make_response
    raise TypeError(
TypeError: The view function for 'index' did not return a valid response. The function either returned None or ended without a return statement.
192.168.86.22 - - [18/Apr/2022 08:34:56] "GET / HTTP/1.1" 500 -
192.168.86.22 - - [18/Apr/2022 08:34:56] "GET /favicon.ico HTTP/1.1" 404 -
[2022-04-18 08:35:27,591] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1526, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1545, in finalize_request
    response = self.make_response(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1701, in make_response
    raise TypeError(
TypeError: The view function for 'index' did not return a valid response. The function either returned None or ended without a return statement.
192.168.86.22 - - [18/Apr/2022 08:35:27] "GET / HTTP/1.1" 500 -
192.168.86.22 - - [18/Apr/2022 08:35:27] "GET /favicon.ico HTTP/1.1" 404 -
[2022-04-18 08:35:34,258] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1526, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1545, in finalize_request
    response = self.make_response(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1701, in make_response
    raise TypeError(
TypeError: The view function for 'index' did not return a valid response. The function either returned None or ended without a return statement.
192.168.86.22 - - [18/Apr/2022 08:35:34] "GET / HTTP/1.1" 500 -
192.168.86.50 - - [18/Apr/2022 08:42:33] "GET /static/style.css HTTP/1.1" 304 -
192.168.86.50 - - [18/Apr/2022 08:42:39] "GET /favicon.ico HTTP/1.1" 404 -
192.168.86.50 - - [18/Apr/2022 08:42:50] "GET /static/style.css HTTP/1.1" 304 -
192.168.86.50 - - [18/Apr/2022 08:43:00] "GET /static/style.css HTTP/1.1" 304 -

Great! The issue with the publish is easy to fix, I will do it as soon as I can.
As the optimization works you can now test the different configuration options and see what best suit for your case. Notably the type of cost function that you will be using

Hi! Just published v0.1.23 with those data publish issues normally solved. Sorry for these errors. Tested and working just fine using dev-container…

I’ll have a look.

0.1.23 seems to work for a while and I can see the p_load sensor, but then after a while I get a server overloaded error message.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
 * Serving Flask app 'app_server' (lazy loading)
 * Environment: development
 * Debug mode: off
 * Running on all addresses (0.0.0.0)
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://127.0.0.1:5000
 * Running on http://172.30.33.4:5000 (Press CTRL+C to quit)
192.168.86.22 - - [19/Apr/2022 18:36:36] "GET / HTTP/1.1" 200 -
192.168.86.22 - - [19/Apr/2022 18:36:37] "GET /static/style.css HTTP/1.1" 304 -
192.168.86.22 - - [19/Apr/2022 18:36:45] "GET / HTTP/1.1" 200 -
192.168.86.22 - - [19/Apr/2022 18:36:45] "GET /static/style.css HTTP/1.1" 304 -
[2022-04-19 18:37:20,539] WARNING in optimization: Failed LP solve with PULP_CBC_CMD solver, falling back to default Pulp
[2022-04-19 18:37:20,575] WARNING in optimization: Failed LP solve with default Pulp solver, falling back to GLPK_CMD
192.168.86.22 - - [19/Apr/2022 18:37:20] "POST /action/dayahead-optim HTTP/1.1" 201 -
192.168.86.22 - - [19/Apr/2022 18:37:48] "GET / HTTP/1.1" 200 -
192.168.86.22 - - [19/Apr/2022 18:37:48] "GET /static/style.css HTTP/1.1" 304 -
/usr/local/lib/python3.9/dist-packages/emhass/command_line.py:167: FutureWarning:
Passing method to DatetimeIndex.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
192.168.86.22 - - [19/Apr/2022 18:37:55] "POST /action/publish-data HTTP/1.1" 201 -
192.168.86.22 - - [19/Apr/2022 20:21:27] "GET /static/style.css HTTP/1.1" 304 -
192.168.86.22 - - [19/Apr/2022 20:21:27] "GET /favicon.ico HTTP/1.1" 404 -
[2022-04-19 22:03:10,161] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1526, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1545, in finalize_request
    response = self.make_response(rv)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1701, in make_response
    raise TypeError(
TypeError: The view function for 'index' did not return a valid response. The function either returned None or ended without a return statement.
192.168.86.22 - - [19/Apr/2022 22:03:10] "GET / HTTP/1.1" 500 -
192.168.86.22 - - [19/Apr/2022 22:03:10] "GET /favicon.ico HTTP/1.1" 404 -

Even with these errors the app should still be running and you should be able to run optimizations and publish the results to some sensors.
But anyway I’ve just fixed these errors in v0.1.24