Fifo isn’t an official part of EMHASS.
Something I created myself.
Fifo isn’t an official part of EMHASS.
Something I created myself.
For me the same, I’m on Tibber in the Netherlands I have a somewhat bug disguised as a feature: my charger starts charging when I connect my car. I pause it from my mobile phone if I want EMHASS to take control, or let it charge if I prefer that. In case of EMHASS, it will optimize until next 8am, with whatever data is available from Tibber (or Nordpool, the integration I’m using with a recalculation to Tibber NL prices). When at 13:30 new prices come in, the schedule could change if that’s better.
I tried this fifo buffer, i deployed random numbers as you mentioned and then put similar push values but it doesnt work.
Do you need power no load value to be set as per? Mines sensor.consumption.
When i deploy this into the payload as tours is i change it to sensor.consumption and nothing works. The logs say it cant calculate optimisation.
Ive setup the automation and fifobuffer as per your previous post.
“load_power_forecast”: {{
([states(‘sensor.power_load_no_var_loads’)|int] +
(states(‘input_text.fi_fo_buffer’).split(', ')|map(‘multiply’,1000)|map(‘int’)|list)[1:]
)| tojson
}},
Can you share the logs, we can’t see what is going on.
What does that load forecast expand to?
If you’re a node-red user I’ve got the same thing in node-red.
[{"id":"e6833878191a3648","type":"api-current-state","z":"65840aa926d9c567","name":"","server":"afc27684.cf6ed8","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.fifo_buffer","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":220,"y":3260,"wires":[["c2b7aef7a74ada86"]]},{"id":"c2b7aef7a74ada86","type":"function","z":"65840aa926d9c567","name":"FIFO the input text","func":"// Get the values from the previous nodes\nlet fiFoBuffer = msg.payload.substring(msg.payload.indexOf(',') + 1);\nlet avgHousePower = flow.get(\"flowAvgHousePower\");\nlet comerString = \",\"\n\n// Combine values, and comer and create a string\nlet newValue = fiFoBuffer.concat(comerString.concat(avgHousePower));\n\n// Set the payload to the new value\nmsg.payload = newValue;\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":3240,"wires":[["3e2215cdd1b5a4ac","8d497005f65ec71b"]]},{"id":"3e2215cdd1b5a4ac","type":"api-call-service","z":"65840aa926d9c567","name":"","server":"afc27684.cf6ed8","version":5,"debugenabled":true,"domain":"input_text","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_text.fifo_buffer"],"data":"{\"value\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":820,"y":3240,"wires":[[]]},{"id":"8d497005f65ec71b","type":"debug","z":"65840aa926d9c567","name":"debug 6","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":3320,"wires":[]},{"id":"ab9db8fade2bc42c","type":"function","z":"65840aa926d9c567","name":"half hour average","func":"var sumHousePower = parseInt(flow.get(\"flowSumHousePower\")) || 0;\nvar iterationCount = flow.get(\"flowIterationCount\") || 0;\nvar avgHousePower = flow.get(\"flowAvgHousePower\") || 0;\nvar msg1 = { payload: 0 };\n\n\niterationCount = iterationCount + 1;\nsumHousePower += parseInt(msg.payload);\n\nflow.set(\"flowSumHousePower\", sumHousePower);\nflow.set(\"flowIterationCount\", iterationCount);\n\n// Determine exit path based on iteration count\nif (iterationCount < 30) {\n var msg2 = { payload: [iterationCount,sumHousePower] };\n return [null, msg2];\n } \nelse {\n // Calculate average power consumption\n var averagePower = sumHousePower / 30;\n\n // Reset flow variables for the next 30 iterations\n sumHousePower = 0;\n iterationCount = 0;\n flow.set(\"flowSumHousePower\", sumHousePower);\n flow.set(\"flowIterationCount\", iterationCount);\n\n // Send the average power out the first exit\n msg1.payload = parseInt(averagePower);\n flow.set(\"flowAvgHousePower\", msg1.payload.toString());\n\n return [msg1, null];\n }\n","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":3380,"wires":[["69a86b65b394b08c","e6833878191a3648"],["71f6efbade6f62f7"]]},{"id":"ab70d43f5a804319","type":"api-current-state","z":"65840aa926d9c567","name":"Current State house power less def","server":"afc27684.cf6ed8","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.house_power_consumption_less_deferrables","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":400,"y":3380,"wires":[["ab9db8fade2bc42c"]]},{"id":"32ba8859361ba366","type":"inject","z":"65840aa926d9c567","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":"60","topic":"","payload":"","payloadType":"date","x":170,"y":3380,"wires":[["ab70d43f5a804319"]]},{"id":"69a86b65b394b08c","type":"debug","z":"65840aa926d9c567","name":"debug 7","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":3380,"wires":[]},{"id":"71f6efbade6f62f7","type":"debug","z":"65840aa926d9c567","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":3440,"wires":[]},{"id":"48a7dfb873c1e2b8","type":"comment","z":"65840aa926d9c567","name":"FIFO Buffer for load_power_forecast ","info":"","x":220,"y":3220,"wires":[]},{"id":"afc27684.cf6ed8","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
You have to create an input-text to go with it.
It’s documented here a bit more in section 8.7 Alternative power consumption forecast.
Greetings Everyone: Bellow is a video discussing PR#334.
This pull request focuses on merging the Standalone & Add-on modes together and changes the concepts of passing in parameters.
I hope this helps in understanding the PR. There is still a lot of documentation & testing to be done, all help in this space is appreciated.
I have issue with battery charge and discharge power forecast.
I’m using MPC that runs every 5 minutes. If i’m looking at the forecast everything looks great. There is a max sell in the evening:
However usually when the sell happens, then the power will go downn in every MPC run causing problem, that i’m not selling as much as was planned and missing the sell opurtunity.
Here is a sample from history:
You can see how the power steps down every MPC run. Yes there are some peaks of load and as I understand that it might be because of Load. MPC uses Now/current values in forecasts and this might be causing it, but nevertheless, battery should then be on max discharge to cover load and max sell to grid.
Same thing happens with charging as well, but in this case there are even no load peaks.
Any ideas what might be causing that?
my emhass conf:
# Configuration file for EMHASS
retrieve_hass_conf:
freq: 60 # The time step to resample retrieved data from hass in minutes
days_to_retrieve: 20 # We will retrieve data from now and up to days_to_retrieve days
var_PV: 'sensor.total_pv_power' # Photovoltaic produced power sensor in Watts
var_load: 'sensor.ss_load_power_without_deferrable' # Household power consumption sensor in Watts (deferrable loads should be substracted)
load_negative: False # Set to True if the retrived load variable is negative by convention
set_zero_min: True # A special treatment for a minimum value saturation to zero. Values below zero are replaced by nans
var_replace_zero: # A list of retrived variables that we would want to replace nans with zeros
- 'sensor.total_pv_power'
var_interp: # A list of retrived variables that we would want to interpolate nan values using linear interpolation
- 'sensor.total_pv_power'
- 'sensor.ss_load_power_without_deferrable'
method_ts_round: 'first' # Set the method for timestamp rounding, options are: first, last and nearest
continual_publish: False # Save published sensor data and check for state change every freq minutes
optim_conf:
set_use_battery: True # consider a battery storage
delta_forecast: 2 # days
num_def_loads: 3
P_deferrable_nom: # Watts
- 2380
- 1000
- 0
def_total_hours: # hours
- 0
- 0
- 0
def_start_timestep: # timesteps
- 0
- 0
- 0
def_end_timestep: # timesteps
- 0
- 0
- 0
treat_def_as_semi_cont: # treat this variable as semi continuous
- True
- True
- True
set_def_constant: # set as a constant fixed value variable with just one startup for each 24h
- False
- False
- False
def_start_penalty: # Set a penalty for each start up of a deferrable load
- 0.0
- 0.0
- 0.0
weather_forecast_method: 'scrapper' # options are 'scrapper', 'csv', 'list', 'solcast' and 'solar.forecast'
load_forecast_method: 'mlforecaster' # options are 'csv' to load a custom load forecast from a CSV file or 'naive' for a persistance model
load_cost_forecast_method: 'hp_hc_periods' # options are 'hp_hc_periods' for peak and non-peak hours contracts and 'csv' to load custom cost from CSV file
list_hp_periods: # list of different tariff periods (only needed if load_cost_forecast_method='hp_hc_periods')
- period_hp_1:
- start: '02:54'
- end: '15:24'
- period_hp_2:
- start: '17:24'
- end: '20:24'
load_cost_hp: 0.1907 # peak hours load cost in €/kWh (only needed if load_cost_forecast_method='hp_hc_periods')
load_cost_hc: 0.1419 # non-peak hours load cost in €/kWh (only needed if load_cost_forecast_method='hp_hc_periods')
prod_price_forecast_method: 'constant' # options are 'constant' for constant fixed value or 'csv' to load custom price forecast from a CSV file
prod_sell_price: 0.065 # power production selling price in €/kWh (only needed if prod_price_forecast_method='constant')
set_total_pv_sell: False # consider that all PV power is injected to the grid (self-consumption with total sell)
lp_solver: 'default' # set the name of the linear programming solver that will be used. Options are 'PULP_CBC_CMD', 'GLPK_CMD' and 'COIN_CMD'.
lp_solver_path: 'empty' # set the path to the LP solver, COIN_CMD default is /usr/bin/cbc
set_nocharge_from_grid: False # avoid battery charging from the grid
set_nodischarge_to_grid: False # avoid battery discharging to the grid
set_battery_dynamic: False # add a constraint to limit the dynamic of the battery power in power per time unit
battery_dynamic_max: 0.5 # maximum dynamic positive power variation in percentage of battery maximum power
battery_dynamic_min: -0.5 # minimum dynamic negative power variation in percentage of battery maximum power
weight_battery_discharge: 0.02 # weight applied in cost function to battery usage for discharge
weight_battery_charge: 0.0 # weight applied in cost function to battery usage for charge
plant_conf:
P_from_grid_max: 13200 # The maximum power that can be supplied by the utility grid in Watts
P_to_grid_max: 13200 # The maximum power that can be supplied to the utility grid in Watts
module_model: # The PV module model
- 'CSUN_Eurasia_Energy_Systems_Industry_and_Trade_CSUN295_60M'
inverter_model: # The PV inverter model
# - 'Fronius_International_GmbH__Fronius_Primo_5_0_1_208_240__240V_'
- 12000
surface_tilt: # The tilt angle of your solar panels
- 30
surface_azimuth: # The azimuth angle of your PV installation
- 205
modules_per_string: # The number of modules per string
- 16
strings_per_inverter: # The number of used strings per inverter
- 1
inverter_is_hybrid: True # Set if it is a hybrid inverter (PV+batteries) or not
compute_curtailment: True
Pd_max: 12000 # If your system has a battery (set_use_battery=True), the maximum discharge power in Watts
Pc_max: 12000 # If your system has a battery (set_use_battery=True), the maximum charge power in Watts
eta_disch: 0.95 # If your system has a battery (set_use_battery=True), the discharge efficiency
eta_ch: 0.95 # If your system has a battery (set_use_battery=True), the charge efficiency
Enom: 22000 # 21200 If your system has a battery (set_use_battery=True), the total capacity of the battery stack in Wh
SOCmin: 0.1 # If your system has a battery (set_use_battery=True), the minimun allowable battery state of charge
SOCmax: 1 # If your system has a battery (set_use_battery=True), the minimun allowable battery state of charge
SOCtarget: 0.10 # If your system has a battery (set_use_battery=True), the desired battery state of charge at the end of each optimization cycle
MPC command:
naive_mpc_optim:
url: http://192.168.1.35:5001/action/naive-mpc-optim
method: POST
content_type: 'application/json'
payload: >-
{
"load_cost_forecast": {{
((state_attr('sensor.nordpool_import', 'raw_today') | map(attribute='value') | list + state_attr('sensor.nordpool_import', 'raw_tomorrow') | map(attribute='value') | list)[now().hour:][:48]) | tojson
}},
"prod_price_forecast": {{
((state_attr('sensor.nordpool_kwh_ee_eur_99_10_0', 'raw_today') | map(attribute='value') | list + state_attr('sensor.nordpool_kwh_ee_eur_99_10_0', 'raw_tomorrow') | map(attribute='value') | list)[now().hour:][:48]) | tojson
}},
"prediction_horizon": {{
(min(48, (((state_attr('sensor.nordpool_kwh_ee_eur_99_10_0', 'raw_today')|map(attribute='value')|list + state_attr('sensor.nordpool_kwh_ee_eur_99_10_0', 'raw_tomorrow') | map(attribute='value')| list)[now().hour:][:48]|list|length)))) | tojson
}},
"pv_power_forecast": {{
(([states('sensor.solcast_pv_forecast_power_now')|int(0)] + state_attr('sensor.solcast_pv_forecast_forecast_today', 'detailedHourly')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',1000)|map('int')|list + state_attr('sensor.solcast_pv_forecast_forecast_tomorrow', 'detailedHourly')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',1000)|map('int')|list) | tojson)
}},
"soc_init": {{
(states('sensor.ss_battery_soc')|int(0))/100
}},
"def_total_hours":[{{ states('sensor.i3s_94_estimated_charge_time')|int(0) }},0,0],
"def_end_timestep":[{{ states('sensor.i3s_hours_until_departure')|int(0) }},0,0],
"var_model": "sensor.ss_load_power_without_deferrable"
}
Could this be as simple as setting/adjusting alpha/beta in your call to the mpc-optim?
As for the new mixed forecast using now/current values, you can play with the settings of the weight of now values over forecast values that will be used. This is done by passing parameters
alpha
andbeta
at runtime. They are both fixed by default at 0.5. See the equation for this here in the docs: The forecast module — emhass 0.8.0 documentation
No it’s not.
I will run it for few days with this and see what are the results:
"alpha": 1,
"beta": 0
I see an odd thing. During the night battery is discharged and according to EMHASS the p_batt_forecast values seem correct, however the real values are lower, hence I will import, unnecesarry power from the grid.
My automation is like this:
data:
target_soc: "{{states('sensor.soc_batt_forecast')|int(0)}}"
power: "{{states('sensor.p_batt_forecast') | int(0)|abs}}"
device_id: <device_id number>
action: huawei_solar.forcible_discharge_soc
I don’t know if device ID is unique so I erased it in this post.
Discharge efficiency is set to 0,92. What could be the cause for too low discharge power?
I run MPC each minute with 30 min intervals. The default action is no charge or discharge.
I find that if you include the load_forecast in the payload and include the current/now value as the first element of the load_forecast then the calculations are correct to the Watt for battery power.
If I don’t include the load_forecast, then EMHASS relies on power_no_var_load sensor but then uses an average rather than the current/now version, even with alpha=0. This maybe an unreported bug.
I have this table to track things closely.
I am using the same load power forecast that you created: so the fi_fo buffer approach, alpha = 1 and beta = 0
load_power_forecast: >-
{{ [states('sensor.power_load_no_var_loads')|int] +
(states('input_text.fi_fo_buffer').split(',')|map('multiply',1000)|map('int')|list)[1:]
}}
With 15 min intervals I use the mlforecaster and there I see the same, so I thought that maybe the fit wasn’t that good (R is quite low) so I switched to 30 min intervals, but I still see the same. Strange.
What the hell, I’m starting to get Infeasible every now and then
But I don’t see any error in the log?
I will admit that I have started to look over my recorder but have made sure that my sensor.power_load_novar_loads has enough history.
2024-09-14 08:26:40,642 - web_server - INFO - >> Setting input data dict
2024-09-14 08:26:40,642 - web_server - INFO - Setting up needed data
2024-09-14 08:26:40,644 - web_server - INFO - Retrieve hass get data method initiated...
2024-09-14 08:26:40,992 - web_server - INFO - Retrieving weather forecast data using method = list
2024-09-14 08:26:40,995 - web_server - INFO - >> Performing naive MPC optimization...
2024-09-14 08:26:40,995 - web_server - INFO - Performing naive MPC optimization
2024-09-14 08:26:41,003 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-09-14 08:26:41,069 - web_server - INFO - Status: Optimal
2024-09-14 08:26:41,069 - web_server - INFO - Total value of the Cost function = 0.75
2024-09-14 08:26:41,261 - web_server - INFO - Passed runtime parameters: {}
2024-09-14 08:26:41,262 - web_server - INFO - >> Setting input data dict
2024-09-14 08:26:41,262 - web_server - INFO - Setting up needed data
2024-09-14 08:26:41,263 - web_server - INFO - >> Publishing data...
2024-09-14 08:26:41,263 - web_server - INFO - Publishing data to HASS instance
2024-09-14 08:26:41,273 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 357.4
2024-09-14 08:26:41,280 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 675.53
2024-09-14 08:26:41,287 - web_server - INFO - Successfully posted to sensor.p_hybrid_inverter = 357.4
2024-09-14 08:26:41,294 - web_server - INFO - Successfully posted to sensor.p_deferrable0 = 0.0
2024-09-14 08:26:41,300 - web_server - INFO - Successfully posted to sensor.p_batt_forecast = 0.0
2024-09-14 08:26:41,306 - web_server - INFO - Successfully posted to sensor.soc_batt_forecast = 4.0
2024-09-14 08:26:41,313 - web_server - INFO - Successfully posted to sensor.p_grid_forecast = 318.13
2024-09-14 08:26:41,319 - web_server - INFO - Successfully posted to sensor.total_cost_fun_value = 0.75
2024-09-14 08:26:41,324 - web_server - INFO - Successfully posted to sensor.optim_status = Optimal
2024-09-14 08:26:41,331 - web_server - INFO - Successfully posted to sensor.unit_load_cost = 0.2
2024-09-14 08:26:41,337 - web_server - INFO - Successfully posted to sensor.unit_prod_price = 0.07
2024-09-14 08:27:41,371 - web_server - INFO - Passed runtime parameters: {'load_cost_forecast': [0.2, 0.23, 0.23, 0.2, 0.16, 0.12, 0.13, 0.16, 0.21, 0.28, 0.28, 0.27, 0.26, 0.24, 0.23, 0.21], 'prod_price_forecast': [0.07, 0.09, 0.09, 0.07, 0.03, 0.0, 0.01, 0.03, 0.07, 0.13, 0.13, 0.13, 0.12, 0.1, 0.09, 0.08], 'prediction_horizon': 16, 'pv_power_forecast': [482, 2524, 4178, 5701, 6399, 6566, 6324, 5664, 4657, 3214, 1825, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 226, 966, 2439, 4069, 5528, 6518, 6969, 6600, 5493, 4324, 2808, 1035, 6, 0, 0, 0, 0], 'load_power_forecast': [704, 414, 439, 615, 616, 603, 613, 613, 654, 759, 638, 611, 1659, 626, 672, 992, 1251, 765, 752, 769, 759, 764, 795, 829, 861, 844, 811, 776, 844, 800, 761, 637, 665, 614, 645, 622, 656, 678, 619, 1468, 739, 1066, 1251, 669, 1011, 1381, 971], 'soc_init': 0.03, 'soc_final': 1.0, 'delta_forecast': 2, 'alpha': 1, 'beta': 0, 'def_total_hours': [0], 'def_end_timestep': [0]}
2024-09-14 08:27:41,371 - web_server - INFO - >> Setting input data dict
2024-09-14 08:27:41,371 - web_server - INFO - Setting up needed data
2024-09-14 08:27:41,373 - web_server - INFO - Retrieve hass get data method initiated...
2024-09-14 08:27:41,728 - web_server - INFO - Retrieving weather forecast data using method = list
2024-09-14 08:27:41,731 - web_server - INFO - >> Performing naive MPC optimization...
2024-09-14 08:27:41,731 - web_server - INFO - Performing naive MPC optimization
2024-09-14 08:27:41,739 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-09-14 08:27:41,796 - web_server - INFO - Status: Infeasible
2024-09-14 08:27:41,796 - web_server - INFO - Total value of the Cost function = 0.91
2024-09-14 08:27:41,986 - web_server - INFO - Passed runtime parameters: {}
2024-09-14 08:27:41,986 - web_server - INFO - >> Setting input data dict
2024-09-14 08:27:41,986 - web_server - INFO - Setting up needed data
2024-09-14 08:27:41,988 - web_server - INFO - >> Publishing data...
2024-09-14 08:27:41,988 - web_server - INFO - Publishing data to HASS instance
2024-09-14 08:27:41,998 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 482
2024-09-14 08:27:42,005 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 704
2024-09-14 08:27:42,012 - web_server - INFO - Successfully posted to sensor.p_hybrid_inverter = 387.0
2024-09-14 08:27:42,018 - web_server - INFO - Successfully posted to sensor.p_deferrable0 = 0.0
2024-09-14 08:27:42,025 - web_server - INFO - Successfully posted to sensor.p_batt_forecast = -95.0
2024-09-14 08:27:42,032 - web_server - INFO - Successfully posted to sensor.soc_batt_forecast = 4.0
2024-09-14 08:27:42,039 - web_server - INFO - Successfully posted to sensor.p_grid_forecast = 317.0
2024-09-14 08:27:42,045 - web_server - INFO - Successfully posted to sensor.total_cost_fun_value = 0.9
2024-09-14 08:27:42,050 - web_server - INFO - Successfully posted to sensor.optim_status = Infeasible
2024-09-14 08:27:42,057 - web_server - INFO - Successfully posted to sensor.unit_load_cost = 0.2
2024-09-14 08:27:42,063 - web_server - INFO - Successfully posted to sensor.unit_prod_price = 0.07
2024-09-14 08:29:40,643 - web_server - INFO - Passed runtime parameters: {'load_cost_forecast': [0.2, 0.23, 0.23, 0.2, 0.16, 0.12, 0.13, 0.16, 0.21, 0.28, 0.28, 0.27, 0.26, 0.24, 0.23, 0.21], 'prod_price_forecast': [0.07, 0.09, 0.09, 0.07, 0.03, 0.0, 0.01, 0.03, 0.07, 0.13, 0.13, 0.13, 0.12, 0.1, 0.09, 0.08], 'prediction_horizon': 16, 'pv_power_forecast': [436, 2524, 4178, 5701, 6399, 6566, 6324, 5664, 4657, 3214, 1825, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 226, 966, 2439, 4069, 5528, 6518, 6969, 6600, 5493, 4324, 2808, 1035, 6, 0, 0, 0, 0], 'load_power_forecast': [728, 439, 615, 616, 603, 613, 613, 654, 759, 638, 611, 1659, 626, 672, 992, 1251, 765, 752, 769, 759, 764, 795, 829, 861, 844, 811, 776, 844, 800, 761, 637, 665, 614, 645, 622, 656, 678, 619, 1468, 739, 1066, 1251, 669, 1011, 1381, 971, 676], 'soc_init': 0.03, 'soc_final': 1.0, 'delta_forecast': 2, 'alpha': 1, 'beta': 0, 'def_total_hours': [0], 'def_end_timestep': [0]}
2024-09-14 08:29:40,643 - web_server - INFO - >> Setting input data dict
2024-09-14 08:29:40,643 - web_server - INFO - Setting up needed data
2024-09-14 08:29:40,645 - web_server - INFO - Retrieve hass get data method initiated...
2024-09-14 08:29:41,004 - web_server - INFO - Retrieving weather forecast data using method = list
2024-09-14 08:29:41,007 - web_server - INFO - >> Performing naive MPC optimization...
2024-09-14 08:29:41,007 - web_server - INFO - Performing naive MPC optimization
2024-09-14 08:29:41,015 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-09-14 08:29:41,073 - web_server - INFO - Status: Infeasible
2024-09-14 08:29:41,073 - web_server - INFO - Total value of the Cost function = 0.92
2024-09-14 08:29:41,266 - web_server - INFO - Passed runtime parameters: {}
2024-09-14 08:29:41,266 - web_server - INFO - >> Setting input data dict
2024-09-14 08:29:41,266 - web_server - INFO - Setting up needed data
2024-09-14 08:29:41,268 - web_server - INFO - >> Publishing data...
2024-09-14 08:29:41,268 - web_server - INFO - Publishing data to HASS instance
2024-09-14 08:29:41,278 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 436
2024-09-14 08:29:41,285 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 728
2024-09-14 08:29:41,292 - web_server - INFO - Successfully posted to sensor.p_hybrid_inverter = 436.0
2024-09-14 08:29:41,299 - web_server - INFO - Successfully posted to sensor.p_deferrable0 = 0.0
2024-09-14 08:29:41,306 - web_server - INFO - Successfully posted to sensor.p_batt_forecast = 0.0
2024-09-14 08:29:41,313 - web_server - INFO - Successfully posted to sensor.soc_batt_forecast = 3.0
2024-09-14 08:29:41,321 - web_server - INFO - Successfully posted to sensor.p_grid_forecast = 292.0
2024-09-14 08:29:41,327 - web_server - INFO - Successfully posted to sensor.total_cost_fun_value = 0.92
2024-09-14 08:29:41,332 - web_server - INFO - Successfully posted to sensor.optim_status = Infeasible
2024-09-14 08:29:41,339 - web_server - INFO - Successfully posted to sensor.unit_load_cost = 0.2
2024-09-14 08:29:41,345 - web_server - INFO - Successfully posted to sensor.unit_prod_price = 0.07
Sometimes I see the same, however after a few iterations it’s on ‘optimal’ again, also no errors in the log
can you please share the payload you are using.
Both my solar panels and inverter are not included in pvlib… For both a variant exists but they do not match the exact type/specs.
How does one use EMHASS in such situation? Are all the people using EMHASS lucky that they panels+inverter is included or is there some other way to make it work?
Can you share the logs so we can see the value going in and coming out?
You can see below my load forecast matches on the way in and out
web_server - INFO - Passed runtime parameters: {'load_cost_forecast': [0.33, 0.34, 0.34, 0.34, 0.34, 0.35, 0.22, 0.22, 0.22, 0.22, 0.21, 0.21, 0.2, 0.2, 0.2, 0.2, 0.19, 0.19, 0.19, 0.18, 0.19, 0.19, 0.19, 0.19, 0.18, 0.14, 0.09, 0.08, 0.07, 0.07, 0.04, 0.04, 0.04, 0.04, 0.04, 0.03, 0.03, 0.03, 0.04, 0.04, 0.04, 0.04, 0.05, 0.08, 0.27, 0.32, 0.37, 0.39, 0.41], 'prod_price_forecast': [0.08, 0.09, 0.09, 0.09, 0.09, 0.1, 0.09, 0.09, 0.1, 0.1, 0.09, 0.08, 0.08, 0.08, 0.08, 0.08, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.06, 0.02, -0.02, -0.03, -0.04, -0.04, -0.04, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.05, -0.04, -0.03, -0.01, 0.03, 0.08, 0.11, 0.13, 0.16], 'load_power_forecast': [228, 400, 300, 400, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 300, 300, 300, 400, 300, 400, 400, 300, 300, 500, 500, 300, 300, 600, 300, 300, 300, 300, 400, 300, 300, 300, 300, 300, 300, 300, 400, 300, 400, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 300, 300, 300, 400, 300, 400, 400, 300, 300, 500, 500, 300, 300, 600, 300, 300, 300, 300, 400, 300, 300, 300, 300, 300, 300], 'pv_power_forecast': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 398, 1346, 2908, 4449, 6258, 7903, 9215, 10392, 11317, 12033, 12089, 12008, 11934, 11899, 11451, 10597, 9702, 8734, 7164, 5382, 3636, 1826, 329, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 421, 1510, 2984, 4668, 6485, 8130, 9617, 10807, 11820, 12467, 13002, 13291, 13261, 13094, 12701, 12009, 11069, 9906, 8465, 6508, 4724, 2843, 856, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'prediction_horizon': 49, 'alpha': 1, 'beta': 0, 'num_def_loads': 6, 'def_total_hours': [8, 0, 0, 1, 0, 0], 'def_end_timestep': [0, 0, 0, 0, 0, 0], 'P_deferrable_nom': [300, 6333, 11520, 11000, 600, 11520], 'def_current_state': [0, 0, 0, 0, 0, 0], 'def_start_penalty': [1, 1, 1, 1, 1, 1], 'treat_def_as_semi_cont': [1, 1, 0, 0, 1, 0], 'set_def_constant': [0, 0, 0, 0, 0, 0], 'soc_init': 0.97, 'soc_final': 1}
2024-09-14 18:15:00,341 - web_server - INFO - >> Setting input data dict
2024-09-14 18:15:00,341 - web_server - INFO - Setting up needed data
2024-09-14 18:15:00,348 - web_server - INFO - Retrieve hass get data method initiated...
2024-09-14 18:15:01,672 - web_server - INFO - Retrieving weather forecast data using method = list
2024-09-14 18:15:01,682 - web_server - INFO - >> Performing naive MPC optimization...
2024-09-14 18:15:01,682 - web_server - INFO - Performing naive MPC optimization
2024-09-14 18:15:01,715 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-09-14 18:15:03,550 - web_server - INFO - Status: Optimal
2024-09-14 18:15:03,551 - web_server - INFO - Total value of the Cost function = 3.06
2024-09-14 18:15:04,569 - web_server - INFO - Passed runtime parameters: {'custom_unit_load_cost_id': {'entity_id': 'sensor.unit_load_cost', 'unit_of_measurement': '$/kWh', 'friendly_name': 'Load Cost'}, 'custom_unit_prod_price_id': {'entity_id': 'sensor.unit_prod_price', 'unit_of_measurement': '$/kWh', 'friendly_name': 'Prod Price'}}
2024-09-14 18:15:04,569 - web_server - INFO - >> Setting input data dict
2024-09-14 18:15:04,569 - web_server - INFO - Setting up needed data
2024-09-14 18:15:04,573 - web_server - INFO - >> Publishing data...
2024-09-14 18:15:04,574 - web_server - INFO - Publishing data to HASS instance
2024-09-14 18:15:04,607 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 0
2024-09-14 18:15:04,632 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 228
``
Mostly they don’t match, see if you can get something close, with roughly the right power levels.
If you setup something like solcast the pvlib data isn’t used so it’s really just to get things started.
I see the same, but ‘twice’. However I would think the second calculation is the one which is used.
2024-09-14 16:20:00,124 - web_server - INFO - Passed runtime parameters: {'publish_prefix': ''}
2024-09-14 16:20:00,126 - web_server - INFO - >> Setting input data dict
2024-09-14 16:20:00,126 - web_server - INFO - Setting up needed data
2024-09-14 16:20:00,159 - web_server - INFO - >> Publishing data...
2024-09-14 16:20:00,160 - web_server - INFO - Publishing data to HASS instance
2024-09-14 16:20:00,200 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 2926
2024-09-14 16:20:00,203 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 203
2024-09-14 16:20:00,206 - web_server - INFO - Successfully posted to sensor.p_hybrid_inverter = 203.0
2024-09-14 16:20:00,209 - web_server - INFO - Successfully posted to sensor.p_deferrable0 = 0.0
2024-09-14 16:20:00,212 - web_server - INFO - Successfully posted to sensor.p_deferrable1 = 0.0
2024-09-14 16:20:00,215 - web_server - INFO - Successfully posted to sensor.p_batt_forecast = -2723.0
2024-09-14 16:20:00,219 - web_server - INFO - Successfully posted to sensor.soc_batt_forecast = 47.35
2024-09-14 16:20:00,223 - web_server - INFO - Successfully posted to sensor.p_grid_forecast = 0.0
2024-09-14 16:20:00,230 - web_server - INFO - Successfully posted to sensor.total_cost_fun_value = 0.68
2024-09-14 16:20:00,234 - web_server - INFO - Successfully posted to sensor.optim_status = Optimal
2024-09-14 16:20:00,242 - web_server - INFO - Successfully posted to sensor.unit_load_cost = 0.1488
2024-09-14 16:20:00,247 - web_server - INFO - Successfully posted to sensor.unit_prod_price = 0.0021
2024-09-14 16:20:01,084 - web_server - INFO - Passed runtime parameters: {'prediction_horizon': 48, 'pv_power_forecast': [2926, 2639, 2345, 1990, 1650, 1305, 894, 469, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 413, 841, 1200, 1558, 1937, 2347, 2753, 3084, 3285, 3487, 3720, 3900, 3929, 3730, 3332, 2870, 2435, 2131, 1915, 1730, 1514, 1242, 928, 639, 350, 0, 0, 0, 0, 0, 0, 0, 0], 'num_def_loads': 2, 'P_deferrable_nom': [0, 0], 'def_total_hours': [0, 0], 'treat_def_as_semi_cont': [1, 1], 'set_def_constant': [1, 1], 'def_start_timestep': [0, 0], 'def_end_timestep': [0, 0], 'soc_init': 0.39, 'soc_final': 0.9, 'load_cost_forecast': [0.1488, 0.1488, 0.1972, 0.1972, 0.2337, 0.2337, 0.2505, 0.2505, 0.2601, 0.2601, 0.2329, 0.2329, 0.2335, 0.2335, 0.2278, 0.2278, 0.2177, 0.2177, 0.2104, 0.2104, 0.2038, 0.2038, 0.2034, 0.2034, 0.1998, 0.1998, 0.2022, 0.2022, 0.2061, 0.2061, 0.2233, 0.2233, 0.217, 0.217, 0.1738, 0.1738, 0.1485, 0.1485, 0.137, 0.137, 0.137, 0.137, 0.1369, 0.1369, 0.1365, 0.1365, 0.1368, 0.1368], 'prod_price_forecast': [0.0021, 0.0021, 0.0478, 0.0478, 0.0822, 0.0822, 0.098, 0.098, 0.1071, 0.1071, 0.0814, 0.0814, 0.082, 0.082, 0.0766, 0.0766, 0.0672, 0.0672, 0.0602, 0.0602, 0.0541, 0.0541, 0.0536, 0.0536, 0.0502, 0.0502, 0.0525, 0.0525, 0.0561, 0.0561, 0.0724, 0.0724, 0.0665, 0.0665, 0.0257, 0.0257, 0.0019, 0.0019, -0.009, -0.009, -0.0091, -0.0091, -0.0091, -0.0091, -0.0094, -0.0094, -0.0092, -0.0092], 'alpha': 1, 'beta': 0, 'load_power_forecast': [175, 200, 100, 300, 400, 500, 400, 400, 400, 500, 400, 300, 200, 300, 300, 200, 200, 200, 300, 300, 200, 200, 200, 300, 200, 200, 200, 400, 300, 200, 200, 400, 300, 300, 200, 200, 300, 300, 200, 200, 200, 300, 200, 200, 200, 200, 300, 200]}
2024-09-14 16:20:01,084 - web_server - INFO - >> Setting input data dict
2024-09-14 16:20:01,084 - web_server - INFO - Setting up needed data
2024-09-14 16:20:01,090 - web_server - INFO - Retrieve hass get data method initiated...
2024-09-14 16:20:01,347 - web_server - INFO - Retrieving weather forecast data using method = list
2024-09-14 16:20:01,349 - web_server - INFO - >> Performing naive MPC optimization...
2024-09-14 16:20:01,349 - web_server - INFO - Performing naive MPC optimization
2024-09-14 16:20:01,354 - web_server - INFO - Perform an iteration of a naive MPC controller
2024-09-14 16:20:01,565 - web_server - INFO - Status: Optimal
2024-09-14 16:20:01,565 - web_server - INFO - Total value of the Cost function = 0.89
2024-09-14 16:20:01,718 - web_server - INFO - Passed runtime parameters: {'publish_prefix': ''}
2024-09-14 16:20:01,718 - web_server - INFO - >> Setting input data dict
2024-09-14 16:20:01,719 - web_server - INFO - Setting up needed data
2024-09-14 16:20:01,720 - web_server - INFO - >> Publishing data...
2024-09-14 16:20:01,720 - web_server - INFO - Publishing data to HASS instance
2024-09-14 16:20:01,727 - web_server - INFO - Successfully posted to sensor.p_pv_forecast = 2926
2024-09-14 16:20:01,730 - web_server - INFO - Successfully posted to sensor.p_load_forecast = 175
2024-09-14 16:20:01,734 - web_server - INFO - Successfully posted to sensor.p_hybrid_inverter = 175.0
2024-09-14 16:20:01,737 - web_server - INFO - Successfully posted to sensor.p_deferrable0 = 0.0
2024-09-14 16:20:01,740 - web_server - INFO - Successfully posted to sensor.p_deferrable1 = 0.0
2024-09-14 16:20:01,743 - web_server - INFO - Successfully posted to sensor.p_batt_forecast = -2751.0
2024-09-14 16:20:01,747 - web_server - INFO - Successfully posted to sensor.soc_batt_forecast = 47.44
2024-09-14 16:20:01,751 - web_server - INFO - Successfully posted to sensor.p_grid_forecast = 0.0
2024-09-14 16:20:01,754 - web_server - INFO - Successfully posted to sensor.total_cost_fun_value = 0.68
2024-09-14 16:20:01,757 - web_server - INFO - Successfully posted to sensor.optim_status = Optimal
2024-09-14 16:20:01,760 - web_server - INFO - Successfully posted to sensor.unit_load_cost = 0.1488
2024-09-14 16:20:01,762 - web_server - INFO - Successfully posted to sensor.unit_prod_price = 0.0021
I found the cause but no the solution yet. The real discharge power is lower then requested. The Discharge power should be 334W and I get only -305 W. Anyone with Huawei Inverter and batteries experiences the same?