EMHASS: An Energy Management for Home Assistant

Is there a planning for a HACS/Add-On release?

Hi. I’m working on it whenever I get some spare time, so I can’t take the engagement of a release date. But it will be anytime soon in the following 3 to 4 weeks

2 Likes

Amazing looking forward. Let me know if you need testers.

Hi David, i’m very exited if you would release an HACS Release. Could you provide us a little Update of the development? I’d like to test the Add-on :slight_smile:

Hi, yes just found some spare time lately. I’m working on it.
Here is my repo: GitHub - davidusb-geek/emhass-add-on: The Home Assistant Add-on for EMHASS: Energy Management Optimization for Home Assistant
However is totally a work in progress. I’m currently stuck on my add-on installation and using pip3 on the Dockerfile… Right now looking for a solution.

2 Likes

Hi everyone, I just released the first version of this add-on.

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

I am presenting this add-on on this new topic:

Feel free to test it and give me any feedback.
If you encounter any problem you can directly open an issue on the add-on repository: Issues · davidusb-geek/emhass-add-on · GitHub

Cheers!!!

1 Like

Thank you for this.

I get a “Invalid Add-on repository!” when adding the Github repository “GitHub - davidusb-geek/emhass: emhass: Energy Management for Home Assistant

Any suggestions please?

Hi, yes you should be adding the add-on repository and not the emhass module repository.

Add this: GitHub - davidusb-geek/emhass-add-on: The Home Assistant Add-on for EMHASS: Energy Management Optimization for Home Assistant

I got the error: The command ‘/bin/sh -c apt-get update && apt-get install -y --no-install-recommends git && pip3 install --no-cache-dir -r requirements.txt’ returned a non-zero code: 1

Mmmm a quick search talked about this error when the “-y” option is missing, however this option is there in that command. What is your setup?

Raspberry with home assistant HAOS on raspberry 3 (32bit)

Any chance of more details from your supervisor logs?

          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/setup.py", line 443, in <module>
            setup_package()
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/setup.py", line 435, in setup_package
            setup(**metadata)
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/core.py", line 171, in setup
            return old_setup(**new_attr)
          File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
            return distutils.core.setup(**attrs)
          File "/usr/local/lib/python3.8/distutils/core.py", line 148, in setup
            dist.run_commands()
          File "/usr/local/lib/python3.8/distutils/dist.py", line 966, in run_commands
            self.run_command(cmd)
          File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/install.py", line 62, in run
            r = self.setuptools_run()
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/install.py", line 36, in setuptools_run
            return distutils_install.run(self)
          File "/usr/local/lib/python3.8/distutils/command/install.py", line 545, in run
            self.run_command('build')
          File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/build.py", line 47, in run
            old_build.run(self)
          File "/usr/local/lib/python3.8/distutils/command/build.py", line 135, in run
            self.run_command(cmd_name)
          File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/build_src.py", line 142, in run
            self.build_sources()
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/build_src.py", line 153, in build_sources
            self.build_library_sources(*libname_info)
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/build_src.py", line 286, in build_library_sources
            sources = self.generate_sources(sources, (lib_name, build_info))
          File "/tmp/pip-install-2gih2rmj/numpy_1441dd882a91498892b69d0ea99d79cc/numpy/distutils/command/build_src.py", line 369, in generate_sources
            source = func(extension, build_dir)
          File "numpy/core/setup.py", line 669, in get_mathlib_info
            raise RuntimeError("Broken toolchain: cannot link a simple C program")
        RuntimeError: Broken toolchain: cannot link a simple C program
        [end of output]
  
    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: legacy-install-failure
  
  × Encountered error while trying to install package.
  ╰─> numpy
  
  note: This is an issue with the package mentioned above, not pip.
  hint: See above for output from the failure.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
– See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.

Removing intermediate container 89876dbb4803

Same error here:

The command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends git && pip3 install --no-cache-dir -r requirements.txt' returned a non-zero code: 1

Running:
|core-2022.3.5|
|Home Assistant Supervised|

On a PI4

Ok, trying to solve this right now. I didn’t tested it on arm archs, just amd64 and it worked fine… I will try now to create a Dockerfile for multiple architectures, including PI4 arm’s…

Right. Could you please try now? I just pushed a new version with a quick fix that will hopefully overcome that Numpy installation problem. If the problem persists I will later switch to official hass docker images for each arch.

Fantastic project and I look forward to getting things running.

Version 0.1.16 loaded correctly on my odroid n2+, which is the same hardware as HA Blue so that is a start.

I am not currently on my local network, and access HA via Nabu Casa, so I presume I cannot access EMHASS, which makes control difficult outside of LAN. Interesting other Add-On’s can still access localhost, so there maybe a way around that I haven’t identifed.

I have multiple inverters with multiple strings pointing in different directions, which doesn’t seem to be supported in the EMHASS configuration setup. I am also interested in the use of pvlib within EMHASS given the HA energy dashboard already has good support for solar forecasting though either the Solcast or Forecast.Solar integrations, which in my case are already setup.

EMHASS assumes that the solar compensation, TOU pricing and timings are constant, but there are other cases. I have forecast and actual feed in and general tariff pricing available in 30 minute blocks vi the Amber Electric Integration. That is OK, I can make a steady state approximation as to my TOU windows and pricing, but something to consider for the future, and something that would really benefit from the LP, although I suspect the calculations may need to occur more than once a day as my forecast pricing is updated every 30 minutes.

EMHASS assumes that the deferable loads needs to run for a fixed number of hours but there are other cases. My EV/ Home Battery charging time is an inverse function with its state of charge, the Power draw for EV charging can also be modulated to self consume excess solar, my Pool Heating time is a function of the temperature difference with the desired set point. My HVAC running time is a bizzare function of the temperature difference with the desired set point with an allowance for pre heating/ cooling before electricity price peak windows.

So looking forward to seeing how far we can push EMHASS.

1 Like

Great project ! I am really interested as I have to ideally maximize the usage of my solar production to minimize my electricity bill but also minimize the price for installing batteries in the future… EMHASS combined with the recording of the power consummed by some of my equipments (a total of 22), the battery simulator (battery_sim) and the energy dashboard, will allow me to meet my objectives I think.

Tried just now on 0.1.16


but getting an error:

Hi thanks for the feedback!

Version 0.1.16 loaded correctly on my odroid n2+, which is the same hardware as HA Blue so that is a start.

You will need to rebuild as I have just updated EMHASS (the module not the add-on)

I am not currently on my local network, and access HA via Nabu Casa, so I presume I cannot access EMHASS, which makes control difficult outside of LAN. Interesting other Add-On’s can still access localhost, so there maybe a way around that I haven’t identifed.

Ok so in version 0.1.16 (the latest) I’m using directly communication with the supervisor. So EMHASS should be able to communicate directly with your hass core instance. Have you tested the connection?

I have multiple inverters with multiple strings pointing in different directions, which doesn’t seem to be supported in the EMHASS configuration setup. I am also interested in the use of pvlib within EMHASS given the HA energy dashboard already has good support for solar forecasting though either the Solcast or Forecast.Solar integrations, which in my case are already setup.

Ok this is a very nice use case, I will definitely update the code in the near future to support multiple inverters. The core code is actually ready for this as everything is in lists, so you we could have a list of inverters with no problem. But I will need to work a little bit further on the add-on.

For you to use PVLib inside EMHASS you will have to provide and pass the irradiance and temperature forecasts provided by whatever service you want. As you said this is already implemented in HA, so it will be nice to retrieve these forecasts directly. This is already possible using your own CSV files with my EMHASS Python module but not the Add-on. I will also update the add-on for you to be able to import directly the variables from those forecasting services you mentioned. I will work on it.

EMHASS assumes that the solar compensation, TOU pricing and timings are constant, but there are other cases. I have forecast and actual feed in and general tariff pricing available in 30 minute blocks vi the Amber Electric Integration. That is OK, I can make a steady state approximation as to my TOU windows and pricing, but something to consider for the future, and something that would really benefit from the LP, although I suspect the calculations may need to occur more than once a day as my forecast pricing is updated every 30 minutes.

Again this is actually already implemented in the EMHASS Python module but still not in the add-on. I was trying to figure out how to possible import variable pricings. The Amber Electric integration is just for AU users, so I will need to find a more generalized solution. How to feed a forecast variable to EMHASS?

EMHASS assumes that the deferable loads needs to run for a fixed number of hours but there are other cases. My EV/ Home Battery charging time is an inverse function with its state of charge, the Power draw for EV charging can also be modulated to self consume excess solar, my Pool Heating time is a function of the temperature difference with the desired set point. My HVAC running time is a bizzare function of the temperature difference with the desired set point with an allowance for pre heating/ cooling before electricity price peak windows.

There are definitely a lot of using cases to take care of. For now an answer to the EV case. You can consider adding a battery to EMHASS and fix a discharging power to zero and a target SOC to whatever SOC you want the EV to be at the end of the day.

1 Like