EMHASS: An Energy Management for Home Assistant

Other than the missing items in your configuration I don’t see any other issue with your config. There was also missing: lp_solver_path: 'empty'.

You are using MPC right?
Copy your shell command and past it in a console to perform the curl commande directly in the console. What is the logged output?

so, woke up looked at emhass webpage and suddenly the nordpool prices where in.
Changed the sensor for pv from accumulated to live production andsuddenly back to emhass setting prices? does it need to populate or what happend?

and for the to sensors photovoltic and no load, should it be accumulated or liva data

cheers

I don’t know what is your definition of accumulated or live data but for EMHASS all power sensors should be in Watts, not Watt-hour or others units. So don’t cumulate anything.

If I activate lp_solver_path (not sure if I have to put anything into the specified folder or where I should get what needs to be placed there), I don’t get any result.

Having my “normal” config, i get the following in the log:

2023-03-20T09:02:32.968854031Z	stdout	TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
2023-03-20T09:02:32.968788905Z	stdout	    opt_tp["P_grid"] = [P_grid_pos[i].varValue + P_grid_neg[i].varValue for i in set_I]
2023-03-20T09:02:32.968719792Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/optimization.py", line 390, in <listcomp>
2023-03-20T09:02:32.968627903Z	stdout	    opt_tp["P_grid"] = [P_grid_pos[i].varValue + P_grid_neg[i].varValue for i in set_I]
2023-03-20T09:02:32.968550476Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/optimization.py", line 390, in perform_optimization
2023-03-20T09:02:32.968486300Z	stdout	    self.opt_res = self.perform_optimization(df_input_data, P_PV.values.ravel(), P_load.values.ravel(),
2023-03-20T09:02:32.968416349Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/optimization.py", line 547, in perform_naive_mpc_optim
2023-03-20T09:02:32.968264709Z	stdout	    opt_res_naive_mpc = input_data_dict['opt'].perform_naive_mpc_optim(
2023-03-20T09:02:32.968193946Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/command_line.py", line 274, in naive_mpc_optim
2023-03-20T09:02:32.968139357Z	stdout	    opt_res = naive_mpc_optim(input_data_dict, app.logger)
2023-03-20T09:02:32.968066981Z	stdout	  File "src/emhass/web_server.py", line 195, in action_call
2023-03-20T09:02:32.968009005Z	stdout	    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-03-20T09:02:32.967949842Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
2023-03-20T09:02:32.967898641Z	stdout	    rv = self.dispatch_request()
2023-03-20T09:02:32.967838927Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
2023-03-20T09:02:32.967786564Z	stdout	    rv = self.handle_user_exception(e)
2023-03-20T09:02:32.967727876Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request
2023-03-20T09:02:32.967675125Z	stdout	    response = self.full_dispatch_request()
2023-03-20T09:02:32.967607311Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_app

Ok so that’s the problem.
The LP problem is not being solved at all.
You need to setup that CBC solver path or use the COIN_CMD solver.

If you are using:

lp_solver: 'PULP_CBC_CMD'

Then set:

lp_solver_path: 'empty'

If that doesn’t work try to understand whi it isn’t working with the logs as before.

Otherwise use:

lp_solver: 'COIN_CMD'
lp_solver_path: '/usr/bin/cbc'

You can always check the path where your solver is installed.
To do that go inside the running emhass docker container and look for the correct path where the solver is installed in your case.

To go inside the container use:

docker exec -it CONTAINER_ID /bin/bash

And navigate to /usr/bin/cbc to check that the solver is there.

Ok so the first options did not work. PULP_CBC_CMD with empty lp_solver_path returned the same results as previously.

COIN_CMD with /usr/bin/cbc results in errors.

I now did

docker exec -it containercode /bin/bash

which put me in the folder /app.
doing … and then going to /bin, I can’t find any cbc folder / file.
How should I get it there?

What errors? Could you show them?

You can also check this. From inside the docker container open a Python console using python3, then type this:

import pulp as plp
solver_list = plp.listSolvers()
print(solver_list)

What is the printed output?

That’s my output from the python:
[‘GLPK_CMD’, ‘PYGLPK’, ‘CPLEX_CMD’, ‘CPLEX_PY’, ‘GUROBI’, ‘GUROBI_CMD’, ‘MOSEK’, ‘XPRESS’, ‘XPRESS’, ‘XPRESS_PY’, ‘PULP_CBC_CMD’, ‘COIN_CMD’, ‘COINMP_DLL’, ‘CHOCO_CMD’, ‘MIPCL_CMD’, ‘SCIP_CMD’, ‘HiGHS_CMD’]

Regarding the errors:
The pyhton errors listed in EMHASS: An Energy Management for Home Assistant - #528 by smi

Ok please while inside that very same Python console type this and post the results:

import pulp as plp
plp.pulpTestAll()

Here is the resulting output:

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 reading MPS files - noname
..       Testing invalid var names
.        Testing logPath argument
.        Testing makeDict general behavior
.        Testing makeDict default value behavior
.        Testing measuring optimization time
.        Testing that `readsol` can parse CPLEX mipopt solution
.        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 dual variables and slacks reporting
...      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
...sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
----------------------------------------------------------------------
Ran 1003 tests in 17.827s

OK (skipped=944)

No problem on the testing but it skipped a lot of tests. This is tricky.
Please bear with me and test this:

import pulp as plp
solver_list = plp.listSolvers(onlyAvailable=True)

Also try to import the solvers mannually like this:

import pulp as plp
solver = plp.getSolver('COIN_CMD')
solver = plp.getSolver('PULP_CBC_CMD')
solver = plp.getSolver('GLPK_CMD')

Do you get any errors with those?

Both commands do not provide any output.

Still getting

2023-03-20T14:00:13.835447309Z	stdout	ValueError: Shape of passed values is (18, 1), indices imply (19, 1)
2023-03-20T14:00:13.835367883Z	stdout	    raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
2023-03-20T14:00:13.835291506Z	stdout	  File "/usr/local/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 422, in _check_values_indices_shape_match
2023-03-20T14:00:13.835222105Z	stdout	    _check_values_indices_shape_match(values, index, columns)
2023-03-20T14:00:13.835145542Z	stdout	  File "/usr/local/lib/python3.8/site-packages/pandas/core/internals/construction.py", line 351, in ndarray_to_mgr
2023-03-20T14:00:13.835059003Z	stdout	    mgr = ndarray_to_mgr(
2023-03-20T14:00:13.834901325Z	stdout	  File "/usr/local/lib/python3.8/site-packages/pandas/core/frame.py", line 694, in __init__
2023-03-20T14:00:13.834745660Z	stdout	    forecast_out = pd.DataFrame(
2023-03-20T14:00:13.834588757Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/forecast.py", line 522, in get_forecast_out_from_csv
2023-03-20T14:00:13.834432342Z	stdout	    forecast_out = self.get_forecast_out_from_csv(
2023-03-20T14:00:13.834272865Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/forecast.py", line 705, in get_load_cost_forecast
2023-03-20T14:00:13.834103375Z	stdout	    df_input_data_dayahead = input_data_dict['fcst'].get_load_cost_forecast(
2023-03-20T14:00:13.833458489Z	stdout	  File "/usr/local/lib/python3.8/site-packages/emhass-0.4.8-py3.8.egg/emhass/command_line.py", line 264, in naive_mpc_optim
2023-03-20T14:00:13.832742090Z	stdout	    opt_res = naive_mpc_optim(input_data_dict, app.logger)
2023-03-20T14:00:13.832659863Z	stdout	  File "src/emhass/web_server.py", line 195, in action_call
2023-03-20T14:00:13.832585825Z	stdout	    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-03-20T14:00:13.832504986Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
2023-03-20T14:00:13.832416947Z	stdout	    rv = self.dispatch_request()
2023-03-20T14:00:13.832339721Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
2023-03-20T14:00:13.832239419Z	stdout	    rv = self.handle_user_exception(e)
2023-03-20T14:00:13.832151243Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request
2023-03-20T14:00:13.832039116Z	stdout	    response = self.full_dispatch_request()
2023-03-20T14:00:13.831919639Z	stdout	  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_app
2023-03-20T14:00:13.831817412Z	stdout	Traceback (most recent call last):
2023-03-20T14:00:13.831725936Z	stdout	2023-03-20 15:00:13,459 - web_server - ERROR - Exception on /action/naive-mpc-optim [POST]

The strange thing is that I do not always get the error. Sometimes its just infeasible and so on:

date	stream	content
2023-03-20T14:05:28.732428448Z	stdout	2023-03-20 15:05:28,731 - web_server - INFO - Perform an iteration of a naive MPC controller
2023-03-20T14:05:28.695987004Z	stdout	2023-03-20 15:05:28,695 - web_server - INFO - Performing naive MPC optimization
2023-03-20T14:05:28.695276530Z	stdout	2023-03-20 15:05:28,694 - web_server - INFO -  >> Performing naive MPC optimization...
2023-03-20T14:05:16.871901231Z	stdout	2023-03-20 15:05:16,871 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:05:16.870058338Z	stdout	2023-03-20 15:05:16,869 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2023-03-20T14:05:16.866424441Z	stdout	2023-03-20 15:05:16,865 - web_server - INFO - Retrieving weather forecast data using method = list
2023-03-20T14:05:12.984717949Z	stdout	2023-03-20 15:05:12,984 - web_server - INFO - Total value of the Cost function = -0.24
2023-03-20T14:05:12.984358818Z	stdout	2023-03-20 15:05:12,983 - web_server - INFO - Status: Infeasible
2023-03-20T14:05:12.851454925Z	stdout	2023-03-20 15:05:12,850 - web_server - INFO - Perform an iteration of a naive MPC controller
2023-03-20T14:05:12.813338629Z	stdout	2023-03-20 15:05:12,812 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:05:12.804643249Z	stdout	2023-03-20 15:05:12,804 - web_server - INFO - Setting up needed data
2023-03-20T14:05:12.790336916Z	stdout	2023-03-20 15:05:12,789 - web_server - INFO - Performing naive MPC optimization
2023-03-20T14:05:12.789372500Z	stdout	2023-03-20 15:05:12,788 - web_server - INFO -  >> Performing naive MPC optimization...
2023-03-20T14:04:59.719468748Z	stdout	2023-03-20 15:04:59,719 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:04:59.717977299Z	stdout	2023-03-20 15:04:59,717 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2023-03-20T14:04:59.713796068Z	stdout	2023-03-20 15:04:59,713 - web_server - INFO - Retrieving weather forecast data using method = list
2023-03-20T14:04:56.265117038Z	stdout	2023-03-20 15:04:55,807 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:04:56.265023361Z	stdout	2023-03-20 15:04:55,800 - web_server - INFO - Setting up needed data
2023-03-20T14:04:56.264959722Z	stdout	2023-03-20 15:04:55,523 - web_server - INFO - Successfully posted to sensor.total_cost_fun_value = -0.24
2023-03-20T14:04:56.264895996Z	stdout	2023-03-20 15:04:55,501 - web_server - INFO - Successfully posted to sensor.p_grid_forecast = 468.89
2023-03-20T14:04:56.264831158Z	stdout	2023-03-20 15:04:55,475 - web_server - INFO - Successfully posted to sensor.p_deferrable0 = 643.0
2023-03-20T14:04:56.264682768Z	stdout	2023-03-20 15:04:55,447 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 528.67
2023-03-20T14:04:55.421960799Z	stdout	2023-03-20 15:04:55,421 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 702.78
2023-03-20T14:04:55.383227618Z	stdout	2023-03-20 15:04:55,382 - web_server - INFO - Publishing data to HASS instance
2023-03-20T14:04:55.382966613Z	stdout	2023-03-20 15:04:55,382 - web_server - INFO -  >> Publishing data...
2023-03-20T14:04:55.377259720Z	stdout	2023-03-20 15:04:55,376 - web_server - INFO - Setting up needed data
2023-03-20T14:03:43.922137651Z	stdout	2023-03-20 15:03:43,921 - web_server - INFO - Total value of the Cost function = -0.24
2023-03-20T14:03:43.921356488Z	stdout	2023-03-20 15:03:43,920 - web_server - INFO - Status: Infeasible
2023-03-20T14:03:18.564931845Z	stdout	2023-03-20 15:03:18,564 - web_server - INFO - Total value of the Cost function = -0.24
2023-03-20T14:03:18.564528064Z	stdout	2023-03-20 15:03:18,563 - web_server - INFO - Status: Infeasible
2023-03-20T14:03:18.441925465Z	stdout	2023-03-20 15:03:18,440 - web_server - INFO - Perform an iteration of a naive MPC controller
2023-03-20T14:03:18.403213108Z	stdout	2023-03-20 15:03:18,402 - web_server - INFO - Performing naive MPC optimization
2023-03-20T14:03:18.402328681Z	stdout	2023-03-20 15:03:18,401 - web_server - INFO -  >> Performing naive MPC optimization...
2023-03-20T14:03:06.126366334Z	stdout	2023-03-20 15:03:06,126 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:03:06.124971161Z	stdout	2023-03-20 15:03:06,124 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2023-03-20T14:03:06.121124673Z	stdout	2023-03-20 15:03:06,120 - web_server - INFO - Retrieving weather forecast data using method = list
2023-03-20T14:03:01.137620302Z	stdout	2023-03-20 15:03:01,137 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:03:01.129542770Z	stdout	2023-03-20 15:03:01,128 - web_server - INFO - Setting up needed data
2023-03-20T14:02:18.252696057Z	stdout	2023-03-20 15:02:18,252 - web_server - INFO - Perform an iteration of a naive MPC controller
2023-03-20T14:02:18.217167477Z	stdout	2023-03-20 15:02:18,216 - web_server - INFO - Performing naive MPC optimization
2023-03-20T14:02:18.216474791Z	stdout	2023-03-20 15:02:18,215 - web_server - INFO -  >> Performing naive MPC optimization...
2023-03-20T14:02:06.443701347Z	stdout	2023-03-20 15:02:06,443 - web_server - INFO - Retrieve hass get data method initiated...
2023-03-20T14:02:06.441654001Z	stdout	2023-03-20 15:02:06,441 - web_server - INFO - Retrieving data from hass for load forecast using method = naive
2023-03-20T14:02:06.437564459Z	stdout	2023-03-20 15:02:06,436 - web_server - INFO - Retrieving weather forecast data using method = list

What is the period of that MPC? From that log it seems that you are launching it every minute or even less. Don’t do that, it may not have the time to fetch the data. Do MPC every 10min, that will be more than enough.

It was at 5 minutes but I now changed it to 10. I don’t think this is related to those those high P_grid_pos and -neg values which might be related to the wrong calculation of the optimal time when to run deferrable loads.

So I’ve got it up and running.
Does anybody have a battery pack from Huawei, luna2000, and could help me sort out how to charge and discharge depending on price level?

Found this:

Niklas

1 Like

Great news!

Can you share what you did to get things working so we can know for next time?

Do you have a Huawei inverter on your battery?

Have you tried that integration?

Are you currently accessing your inverter using other integrations?

Hi

I just cleaned up my configuration.yaml and
2 days later prices from nordpool showed up.

Yes I have Huawei inverter and running the Huawei integration.
No other integrations running against the inverter.

I am a newbie, as you figured out, so Need help with how to create a service, sensor to be able to forcible charge soc and discharge



index P_PV P_Load P_deferrable0 P_grid_pos P_grid_neg P_grid P_batt SOC_opt unit_load_cost unit_prod_price cost_profit cost_fun_profit
2023-03-21 23:00:00+01:00 -3.000000 1061.590909 0.0 28759.2940 -9000.0 19759.2940 -18694.703000 1.925997 61.419 61.419 487.569148 487.569148
2023-03-22 00:00:00+01:00 -3.000000 597.712281 0.0 9000.0000 -9000.0 0.0000 600.712280 1.868929 59.994 59.994 504.086849 504.086849
2023-03-22 01:00:00+01:00 -3.000000 580.351916 0.0 9000.0000 -9000.0 0.0000 583.351920 1.807524 49.174 49.174 414.027775 414.027775
2023-03-22 02:00:00+01:00 -3.000000 2845.953237 0.0 9000.0000 -9000.0 0.0000 2848.953200 1.507634 49.146 49.146 302.446782 302.446782
2023-03-22 03:00:00+01:00 -3.000000 583.958333 0.0 9000.0000 -9000.0 0.0000 586.958330 1.445849 48.867 48.867 411.266708 411.266708
2023-03-22 04:00:00+01:00 -3.000000 606.835664 0.0 9000.0000 -9000.0 0.0000 609.835660 1.381656 48.938 48.938 410.744676 410.744676
2023-03-22 05:00:00+01:00 -3.000000 1223.546667 0.0 9000.0000 -9000.0 0.0000 1226.546700 1.265134 49.771 49.771 387.041859 387.041859
2023-03-22 06:00:00+01:00 -3.000000 736.712500 0.0 9000.0000 -9000.0 0.0000 739.712500 1.187269 60.398 60.398 499.086038 499.086038
2023-03-22 07:00:00+01:00 170.996718 100.448276 0.0 8929.4516 -9000.0 -70.5484 0.000000 1.187269 70.662 70.662 628.860124 628.860124
2023-03-22 08:00:00+01:00 764.654111 765.119048 0.0 9000.0000 -9000.0 0.0000 0.464936 1.187220 124.476 124.476 1025.045041 1025.045041
2023-03-22 09:00:00+01:00 1388.268787 275.000000 0.0 9000.0000 -9000.0 0.0000 -1113.268800 1.292981 129.824 129.824 1132.714400 1132.714400
2023-03-22 10:00:00+01:00 1814.176209 1502.307692 0.0 9000.0000 -9000.0 0.0000 -311.868520 1.322608 108.529 108.529 813.717048 813.717048
2023-03-22 11:00:00+01:00 2149.193578 2614.879121 0.0 9000.0000 -9000.0 0.0000 465.685540 1.273589 75.275 75.275 480.639974 480.639974
2023-03-22 12:00:00+01:00 2294.431528 1374.350008 0.0 8079.9185 -9000.0 -920.0815 0.000000 1.273589 51.312 51.312 391.287352 391.287352
2023-03-22 13:00:00+01:00 2237.730763 133.820896 0.0 6896.0901 -9000.0 -2103.9099 0.000000 1.273589 46.784 46.784 414.795323 414.795323
2023-03-22 14:00:00+01:00 1997.616252 165.384615 0.0 9000.0000 -9000.0 0.0000 -1832.231600 1.447651 45.270 45.270 399.943038 399.943038
2023-03-22 15:00:00+01:00 1581.218586 885.426087 0.0 8304.2075 -9000.0 -695.7925 0.000000 1.447651 54.771 54.771 444.443328 444.443328
2023-03-22 16:00:00+01:00 1054.382193 664.651757 0.0 9000.0000 -9000.0 0.0000 -389.730440 1.484675 63.245 63.245 527.169100 527.169100
2023-03-22 17:00:00+01:00 464.326188 4406.311953 0.0 9000.0000 -9000.0 0.0000 3941.985800 1.069729 58.036 58.036 266.599279 266.599279
2023-03-22 18:00:00+01:00 -37.003647 4129.830028 0.0 9000.0000 -9000.0 0.0000 4166.833700 0.673880 59.870 59.870 291.577076 291.577076
2023-03-22 19:00:00+01:00 -3.000000 3118.666667 0.0 9000.0000 -9000.0 0.0000 3121.666700 0.377322 63.647 63.647 374.329223 374.329223
2023-03-22 20:00:00+01:00 -3.000000 782.391304 0.0 9000.0000 -9000.0 0.0000 785.391300 0.302710 54.203 54.203 445.419044 445.419044
2023-03-22 21:00:00+01:00 -3.000000 773.727273 0.0 9000.0000 -9000.0 0.0000 776.727270 0.228920 47.951 47.951 394.458004 394.458004
2023-03-22 22:00:00+01:00 -3.000000 746.744186 0.0 9000.0000 -9000.0 0.0000 749.744190 0.150000 42.256 42.256 348.749578 348.749578

Cost totals for latest optimization results

index Cost Totals
cost_profit 11796.016769
cost_fun_profit 11796.016769

Here is an automation I have on my battery to follow the soc battery forecast from EMHASS.

You will need to change the service call to match the service call for your inverter, but you should get the idea.

Here it is in action:
image

alias: Battery SOC Forecast
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.soc_batt_forecast
condition: []
action:
  - service: number.set_value
    data:
      value: "{{states('sensor.soc_batt_forecast')|int(0)}}"
    target:
      entity_id: number.home_energy_gateway_backup_reserve
mode: single

But you seem to have the same strangely high numbers in P_grid_pos and _neg which I also have

thx will try it, but can’t really find the right entity id…