EMHASS: An Energy Management for Home Assistant

This is how I’ve set it up usinf node-red: ‘My Documentation

2 Likes

I like to try out emhass add on, but i can use help
i haven’t find out how to save the config to get started

“Failed to save add-on configuration, not a valid value”

Reset to default more times, doesn’t help
After reset is “save” grey and after adding data it’s blue
In YAML i think i didn’t miss any of the 61 lines to change, but i can’t find out which line give the error

What do i miss?

HA is running on a proxmox VM
Core2024.1.3 / Supervisor2023.12.0 / Operating System11.4 / Frontend20240104.0

Did you try already with an ESP32 to RS485 for control

If miss one you can add if know the address

I have two Deye SUN-12K -SG04LP3-EU not as parallel running with esp32 in off-grid mode with grid support (Mosttime i am off-grid, as grid connection cost 60W more )
If you use ESP32> RS485 then you have still the RS232 available for another (back) control, I have only the dongle in use for a short moment, when i update the firmware manually from PC.

There is a bug in the default config.

Just update the time for peak hours period.

1 Like

Top, that solved it

Can I now look around for off-grid with grid connection only if I want to swap. (It costs 60W to stay grid-connected for my setup)
I have no peak hours but dynamic hourly prices spot market (entso-e) with net-metering for taxes.

1 Like

EMHASS experts… please take a look!

Could someone please explain a bit the use of weight_battery_discharge and --charge? Are they defined in cents?
When I use weight_battery_charge at 12.0, I assume something like the cost of energy per kwh is increased by 12 cent?

It is in $/ kWh!

I have mine discharge weight set to 0.15 ($/ kWh) and my charge weight set to 0.

This seems to stop my battery from discharging below 15¢/ kWh.

I would set your discharge weight to 0.12.

Thanks for your quick reply! Clear to me! Would this also mean that, for example, if at the beginning of the day the price is $0.12 lower than at a later hour, it will charge (and then discharge later that day) ?

If you would put efficiency to 100% on both discharge and charge it would. Default is 95% on both legs, that means that in addition to the 12 cents you would need to compensate for inefficiency.

That’s exactly what it is planning to do for me today.

2 Likes

A question about the load forecast:
I have a recorder for 30 days in HA, but I am wondering how EMHASS is forecasting the load.
I did a forecast, learning and tuning at some intervals, but it seems it always forcasts the load the same way as the day before.

Example: every saturday I have a higher load during the day, but every friday I have only higher load after 18.00
Does it learn this? I have tried ‘naive’ and ‘mlforecaster’ setting

Hallo - Its really a cool project :smile:. Unfortunately I have a problem with my deferrable loads :cry:. I don’t want the “deferrable loads” to be split after the optimization.

there are 2 deferrable loads defined :

optim_conf:
  - set_use_battery: True # consider a battery storage
  - delta_forecast: 1 # days
  - num_def_loads: 2
  - P_deferrable_nom: # Watts
    - 3600.0
    - 4000.0
  - def_total_hours: # hours
    - 2
    - 0.5
  - treat_def_as_semi_cont: # treat this variable as semi continuous 
    - True
    - True
  - set_def_constant: # set as a constant fixed value variable with just one startup for each 24h
    - True
    - True

I have set set_def_constant to true in config_emhass.yaml. In the result, however, these loads are still split.

How do I get the desired result?

Thanks Thomas

Summary

This text will be hidden

Blockquote
Seems to work now! Just have to wait for actual 12 cents difference :slight_smile:
You have a really nice HA graph, could you share your code for that?

yeah this is still a bug imho. I and some others posted this a while ago and didn’t got this to work. So at the moment i activate my dishwasher when EMHASS would schedule it the first time…
E.g.

Try to put the def constant to false

set_def_constant : false is splitting the defferable loads into separate peaces.

With disabling my battery optimization the opt-process works as expected ! :innocent:

set_def_constant : true is cumulating the load to one block.

But I need my storage to be included in the opti

I’m trying to install the add-on but get a error:
https://github.com/davidusb-geek/emhass is not a valid add-on repository
but I try to add this:

‘https ://github.com/davidusb-geek/emhass-add-on/’

I can however not find anything i’m doing wrong, but I feel I make some stupid mistake here, can anyone help me out?

Ok I already found a solution. restarting HA solved the problem, I found out that I could not add any add-on, it aways showed the same error.

I have difficulties to the the ML forecast model fit running. The perfect optimisation and the day ahead is doing well. This is the error log:

2024-01-20 09:31:46,605 - web_server - INFO - EMHASS server online, serving index.html…
2024-01-20 09:31:49,485 - web_server - INFO - Setting up needed data
2024-01-20 09:31:49,493 - web_server - INFO - Retrieve hass get data method initiated…
2024-01-20 09:31:49,519 - web_server - ERROR - The retrieved JSON is empty, check that correct day or variable names are passed
2024-01-20 09:31:49,520 - web_server - ERROR - 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)
2024-01-20 09:31:49,521 - web_server - ERROR - Exception on /action/forecast-model-fit [POST]
Traceback (most recent call last):
File “/usr/local/lib/python3.11/dist-packages/flask/app.py”, line 1455, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/dist-packages/flask/app.py”, line 869, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/dist-packages/flask/app.py”, line 867, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/dist-packages/flask/app.py”, line 852, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/dist-packages/emhass/web_server.py”, line 181, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/dist-packages/emhass/command_line.py”, line 146, in set_input_data_dict
rh.get_data(days_list, var_list)
File “/usr/local/lib/python3.11/dist-packages/emhass/retrieve_hass.py”, line 150, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
^^^^^^
UnboundLocalError: cannot access local variable ‘df_day’ where it is not associated with a value

any ideas? as mentioned the linear optimisation works, bus the ML optimisation doesn’t.
thanks for any help.

What does your curl command look like?

Have you tried running the same curl command from a terminal session?

Are you using jinja templates in the curl command and do they resolve the way you expect in the Developer Tools demo teplate renderer?