EMHASS: An Energy Management for Home Assistant

I can’t get ML to work, same error as above. Naive does work. Can it be something with the sensor? I waited two days like I found on the forum but maybe the time has to be longer for ML?

How many days of data do you retain in your recorder? How many days are you telling EMHASS to use for ML?

And now, a new day, after midnight, the threshold is 15 (with 16 I get the error). Yesterday it was 14. Recorder always set to 22 days of retention.

I am trying to set two days because the sensor is working since saturday evening.

The default is 9 days but you can change that using the days_to_retrieve key. If set lower than 7 days the code will fail with errors. The ML needs as much history data as possible to obtain meaningful results.

Updating EMHASS addon from 0.4.2 to 0.5.2 still fails.
Also tried rebooting the system including all addons without succes.
HomeAssistant (2023.12.3)
Supervisor (2023.12)
Raspberry Pi 4 ( OS 5.10.103)

        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied````

I have the same exact issue you are having. And it started the 16th I believe

Very strange. I don’t have this issue, with the latest v0.5.2 everything is working fine.

What is the issue?

Hi
this one

but mine looks like this

post_nordpool_forecast: "curl -i -H 'Content-Type: application/json' -X POST -d '{\"load_cost_forecast\":{{( (state_attr('sensor.nordpool', 'raw_tomorrow')|map(attribute='value')|list)[:24]) }},\"prod_price_forecast\":{{( (state_attr('sensor.nordpool', 'raw_tomorrow')|map(attribute='value')|list)[:24])}}}' http://localhost:5000/action/dayahead-optim"

post_nordpool_forecast: "curl -i -H 'Content-Type: application/json' -X POST -d '{\"load_cost_forecast\":[0.161, 0.147, 0.141, 0.141, 0.191, 0.238, 0.378, 0.532, 0.631, 0.7, 0.925, 0.849, 0.845, 0.846, 0.932, 0.953, 0.994, 1.085, 1.046, 0.957, 0.954, 0.889, 0.837, 0.682],\"prod_price_forecast\":[0.161, 0.147, 0.141, 0.141, 0.191, 0.238, 0.378, 0.532, 0.631, 0.7, 0.925, 0.849, 0.845, 0.846, 0.932, 0.953, 0.994, 1.085, 1.046, 0.957, 0.954, 0.889, 0.837, 0.682]}' http://localhost:5000/action/dayahead-optim"
stdout: "HTTP/1.1 400 BAD REQUEST\r\nContent-Length: 167\r\nContent-Type: text/html; charset=utf-8\r\nDate: Tue, 19 Dec 2023 21:10:49 GMT\r\nServer: waitress\r\n\r\n<!doctype html>\n<html lang=en>\n<title>400 Bad Request</title>\n<h1>Bad Request</h1>\n<p>The browser (or proxy) sent a request that this server could not understand.</p>"
stderr: "% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r100   386  100   167  100   219   4542   5957 --:--:-- --:--:-- --:--:-- 10722"
returncode: 0

After the update this morning EMHASS is registering the inputs which it did not do before.
But I have mine setup to read the tomorrow prices from nordpool, which won’t be available for another couple of hours.
So I’ll try it again this afternoon.

I’m letting the ML be for a few days to let the sensor gather more data.
Next problem is I have peak and non-peak hours which is handled by the config but I have to adapt something somewhere because the whole weekend also is non-peak hours, from Friday 10pm till Monday 7 am. It’s not clear to me how i should do this. I have a sensor with the amount that changes when the tariff changes.

You should then pass each time to the command the array with the price forecast for the next 30 minutes slots (if you are using 30 minutes steps)

I’m sorry. I’ve been reading and searching for hours now but I can’t figure out how to put the data from that sensor in a list. Can I use historic values for that? Because every week is the same.

update:
It seems like the problem lies in the installed Python version. My raspberrypi 4 with Raspbian Buster (5.10.103-v7+, armv71) is running Python 3.7.
With that version of Python EMHASS v 0.4.2 was running fine. After updating to v0.5.0 and later v0.5.2 EMHASS failed to start. (See my earlier post).
I installed Python 3.11 and updated EMHASS to version 0.5.3 to find out EMHASS still was not running after which I installed Python 3.9 as-well.
Here is the latest log:

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
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 12, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.11/dist-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied

I see the log is still referring to Python3.11

/usr/local/lib/python3.11/dist-packages/emhass/web_server.py

also the folder /usr/local/lib/pythonx.xx/dist-packages/ does not exist in my system and EMHASS is located at /usr/share/hassio/addons/git/5b918bf2/emhass

For now I’m rolling back again to v0.4.2.

https://emhass.readthedocs.io/en/latest/intro.html#passing-your-own-data

Some examples, but depending on your setup you’ll need to adapt:

Hi. I’m a bit lost here.
Yes since v0.5.0 the main update was switching to Python 3.11. But armv7 architectures are fully supported and the docker image compiled fine, so you should be able to run the add-on without problem.
What is your setup? HAOS or supervised?
How come that you are changing Python versions like that? You shouldn’t care about this because it’s all containerized.

Hi David, Thanks for your help.
I’m running Home Assistant Supervised inside Docker on a Raspberrypi 4 already a few years without ever having any problems like this. As you say, because it’s all containerized you should not have to worry about Python versions.
Because I got stuck with the latest EMHASS v0.5.x updates and found error messages inside the log referring to Python 3.11, I installed Python 3.11 and later 3.9 aswell, changing softlinks to python and python3, etc (I was running Python3.7 before that). This did not make any difference: Updating EMHASS left me again with the same errors.
Yesterday I upgraded my RaspbianOS from Buster to Bullseye (on a life system), which all went well. But again this did not do the trick. EMHASS v0.5.3 starts with the same errors as mentioned before and v0.4.2 is running just fine?!


image

Did the update this morning and now I get this error on rebooting.

json.decoder.JSONDecodeError: Extra data: line 1 column 4 (char 3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 319, in <module>
    config_hass = response.json()
                  ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Extra data: line 1 column 4 (char 3)
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 4 (char 3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/emhass/web_server.py", line 319, in <module>
    config_hass = response.json()
                  ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Extra data: line 1 column 4 (char 3)
s6-supervise emhass: warning: unable to spawn ./finish: Permission denied