Is it possible to set a thermal load as variable?
Hi everyone,
first of all: very nice but also very complex project.
Iâm struggling with several aspects, but first Iâd like to get my pv forecast right.
Right now Iâm pretty off with it: 4kw vs 12kw in reality at peak.
My setup is: three strings (east, south, west) with 12,11,12 module each 450W, one inverter with nominal power 18kw (KACO blueplanet hybrid nh3).
Neither the modules nor the inverter is in the pvlib list, so I went for some Trina Solar modules with 465W and tried different configurations of inverters and strings_per_inverter.
Unfortunately I seem to misunderstand something because forecast is always far too little.
Here is my config:
{
"adjusted_pv_regression_model": "LassoRegression",
"adjusted_pv_solar_elevation_threshold": 10,
"battery_charge_efficiency": 0.95,
"battery_charge_power_max": 1000,
"battery_discharge_efficiency": 0.95,
"battery_discharge_power_max": 1000,
"battery_dynamic_max": 0.9,
"battery_dynamic_min": -0.9,
"battery_maximum_state_of_charge": 0.9,
"battery_minimum_state_of_charge": 0.3,
"battery_nominal_energy_capacity": 5000,
"battery_target_state_of_charge": 0.6,
"compute_curtailment": false,
"continual_publish": false,
"costfun": "self-consumption",
"delta_forecast_daily": 1,
"end_timesteps_of_each_deferrable_load": [
0
],
"historic_days_to_retrieve": 2,
"inverter_is_hybrid": false,
"load_cost_forecast_method": "hp_hc_periods",
"load_forecast_method": "naive",
"load_negative": false,
"load_offpeak_hours_cost": 0.1419,
"load_peak_hour_periods": {
"period_hp_1": [
{
"start": "08:00"
},
{
"end": "12:00"
}
],
"period_hp_2": [
{
"start": "15:00"
},
{
"end": "18:00"
}
]
},
"load_peak_hours_cost": 0.1907,
"logging_level": "INFO",
"lp_solver": "default",
"lp_solver_path": "empty",
"lp_solver_timeout": 45,
"maximum_power_from_grid": 9000,
"maximum_power_to_grid": 9000,
"method_ts_round": "nearest",
"minimum_power_of_deferrable_loads": [
2500
],
"modules_per_string": [
12,
11,
12
],
"nominal_power_of_deferrable_loads": [
7500
],
"num_threads": 0,
"number_of_deferrable_loads": 1,
"open_meteo_cache_max_age": 30,
"operating_hours_of_each_deferrable_load": [
8
],
"optimization_time_step": 60,
"photovoltaic_production_sell_price": 0.07553,
"production_price_forecast_method": "constant",
"pv_inverter_model": [
"Fronius_International_GmbH__Fronius_Primo_10_0_1_208_240__240V_",
"Fronius_International_GmbH__Fronius_Primo_10_0_1_208_240__240V_",
"Fronius_International_GmbH__Fronius_Primo_10_0_1_208_240__240V_"
],
"pv_module_model": [
"Trina_Solar_TSM_465DEG15VC_20_II_"
],
"sensor_linear_interp": [
"sensor.power_photovoltaics"
],
"sensor_power_load_no_var_loads": "sensor.power_load_no_var_loads",
"sensor_power_photovoltaics": "sensor.pv_momentanleistung_ac",
"sensor_power_photovoltaics_forecast": "sensor.p_pv_forecast",
"sensor_replace_zero": [
"sensor.power_photovoltaics"
],
"set_battery_dynamic": false,
"set_deferrable_load_single_constant": [
false
],
"set_deferrable_startup_penalty": [
0
],
"set_nocharge_from_grid": false,
"set_nodischarge_to_grid": true,
"set_total_pv_sell": false,
"set_use_adjusted_pv": false,
"set_use_battery": false,
"set_use_pv": true,
"set_zero_min": true,
"start_timesteps_of_each_deferrable_load": [
0
],
"strings_per_inverter": [
1,
1,
1
],
"surface_azimuth": [
85,
175,
265
],
"surface_tilt": [
21,
21,
21
],
"treat_deferrable_load_as_semi_cont": [
true
],
"weather_forecast_method": "open-meteo",
"weight_battery_charge": 0,
"weight_battery_discharge": 0
}```
Repeat this one 3 times and check, works for me.
Confusion about cost_fun_profit interpretation in EMHASS â is negative good?
Hi all,
Iâm using EMHASS for MPC optimization and Iâm a bit confused about the interpretation of the cost_fun_profit metric shown in the forecast results and output sensors.
Is this correct:
cost_fun_profit = ÎŁ(P_grid_pos Ă unit_load_cost) â ÎŁ(P_grid_neg Ă unit_prod_price)
Where:
P_grid_posis power consumed from the grid (kWh),P_grid_negis power fed back to the grid (kWh),unit_load_costis the electricity price when consuming,unit_prod_priceis the price you receive for feeding back.
From this, I interpret that:
- A lower (more negative)
cost_fun_profitmeans you have more favorable economics (more feed-in revenue than consumption costs). - A positive value means you are spending more on grid consumption than youâre earning from feed-in.
However, someone pointed out that in the EMHASS dashboard (the results table), the cost_fun_profit seems to increase (become more positive) during periods of high PV production and low self-consumption. That would contradict the formula above.
So my questions are:
- Is a more negative
cost_fun_profitvalue better (i.e., higher profit)? - Does the EMHASS results table show the delta per timestep or cumulative cost function?
- Could this perceived inconsistency be due to zero feed-in prices, forecast errors, or simply misinterpretation of the plotted values?
Thanks in advance for helping clarify this!
Thanks, that already improved it. However, optimization status is infeasible now.
[2025-06-21 15:55:38 +0200] [20] [INFO] >> Obtaining params:
[2025-06-21 15:55:38 +0200] [20] [INFO] Passed runtime parameters: {âload_cost_forecastâ: [0.18732, 0.19268, 0.26397, 0.31271, 0.34478, 0.3791, 0.38928, 0.36011, 0.33443, 0.32128, 0.31285, 0.30856, 0.3022, 0.29931, 0.29724, 0.27823, 0.22404, 0.19258, 0.19247, 0.17936, 0.14669, 0.11236, 0.07476, 0.09619], âdef_total_hoursâ: [5]}
[2025-06-21 15:55:38 +0200] [20] [INFO] >> Setting input data dict
[2025-06-21 15:55:38 +0200] [20] [INFO] Setting up needed data
[2025-06-21 15:55:38 +0200] [20] [INFO] Retrieving weather forecast data using method = open-meteo
[2025-06-21 15:55:38 +0200] [20] [INFO] Loading existing cached Open-Meteo JSON file: /data/cached-open-meteo-forecast.json
[2025-06-21 15:55:38 +0200] [20] [INFO] The cached Open-Meteo JSON file is recent (age=2m, max_age=30m)
[2025-06-21 15:55:39 +0200] [20] [INFO] Retrieving data from hass for load forecast using method = naive
[2025-06-21 15:55:39 +0200] [20] [INFO] Retrieve hass get data method initiatedâŚ
[2025-06-21 15:55:41 +0200] [20] [INFO] EMHASS server online, serving index.htmlâŚ
[2025-06-21 15:55:45 +0200] [20] [INFO] >> Performing dayahead optimizationâŚ
[2025-06-21 15:55:45 +0200] [20] [INFO] Performing day-ahead forecast optimization
[2025-06-21 15:55:45 +0200] [20] [INFO] Perform optimization for the day-ahead
[2025-06-21 15:55:45 +0200] [20] [WARNING] Solver default unknown, using default
[2025-06-21 15:55:45 +0200] [20] [INFO] Status: Infeasible
[2025-06-21 15:55:45 +0200] [20] [INFO] Total value of the Cost function = -859.72
[2025-06-21 15:55:45 +0200] [20] [INFO] Optimization status: Infeasible
I just realized that this was yesterdays status.
Today I get an optimal optimization status. Only thing that has changed is âdef_total_hoursâ. Yesterday it was 5, today it is 3.
Is there a reason behind this??
Hi all, Can someone help me verify if thereâs a flaw in my logic? Iâve defined just one load and set its def_total_hours to 0, so it shouldnât run at all. But when EMHASS runs, it still schedules it to run. What am I missing here? Iâve been using EMHASS for over a year and havenât seen this behavior before.
I havenât had this problem, maybe you could try using the updated parameter of operating_hours_of_each_deferrable_load instead of def_total_hours
Sometimes this can happen if your EMHASS configuration has run hours, but your passing runtime payload is set to 0.
Hey. Have been using EMHASS for some time (I posted in here a long time ago).
At the weekend I updated EMHASS to the latest version and switched to the open-meteo forecast for PV generation. This is great and I find it a lot more accurate than the Forecast Solar data that I was manually collecting and passing into EMHASS when I calling naive-mpc-optim.
The one thing I am missing at the moment though is the total forecasted amount of PV generation in KWh for the current day, and for tomorrow. I have some logic that basically overrides some of the models and force charges my battery to 100% if PV generation is below a certain level for the entire day. However Iâm not sure how to achieve this when the open-meteo data is all being handled by EMHASS.
It looks like EMHASS is doing a lot of logic with the weather forecast too, so I dont want to try and replicate that all myself, so itâd be ideal if I could somehow pull out the totals from EMHASS using the API or something. Iâve had a look through the docs, but I donât really see how Iâd do this from Home Assistant.
I did think about just adding up the total values returned via the p_pv entity, but since I run the forecasts every 15mins, this doesnât work, as it only holds forecast from the current time for the next 24hrs.
Any help or suggestions you can offer would be much appreciated, thanks!
I use this approach, just count up the total energy in the future forecasts.
I divide by 2000 to convert the power (W) in EMHASS to 30 minute energy (kWh).
#EMHASS energy forecasts
pv_forecast_energy:
device_class: energy
unit_of_measurement: kWh
value_template: "{{(state_attr('sensor.p_pv_forecast','forecasts')|map(attribute='p_pv_forecast')|map('int')|sum/2000)|round(1)}}"
p_load_forecast_energy:
device_class: energy
unit_of_measurement: kWh
value_template: "{{(state_attr('sensor.p_load_forecast','forecasts')|map(attribute='p_load_forecast')|map('int')|sum/2000)|round(1)}}"
Why do I get infeasible here?
[2025-07-19 13:15:01 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.73, Final SOC: 0.24
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 0 is standard/non-thermal.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 0: Using total timesteps constraint: 8
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 0: Standard load constraints set.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -14 --> 10
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 10
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 1 is standard/non-thermal.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 1: Using total timesteps constraint: 2
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 1: Standard load constraints set.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: -2 --> 16
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 0 --> 16
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 2 --> 16
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 2 --> 16
[2025-07-19 13:15:01 +0200] [21] [INFO] Status: Infeasible
Can it be that âoperating_timesteps_of_each_deferrable_loadâ doesnât work in EMHASS?
Can you show your inputs and configuration settings from earlier in the logs?
Here is some more info:
[2025-07-19 13:15:01 +0200] [21] [INFO] >> Obtaining params:
[2025-07-19 13:15:01 +0200] [21] [INFO] Passed runtime parameters: {'entity_save': 'True', 'publish_prefix': 'mpc_', 'prediction_horizon': 22, 'pv_power_forecast': [3194, 5304, 5169, 4791, 4331, 3836, 3334, 2852, 2384, 1942, 1478, 1009, 661, 433, 260, 131, 46, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 86, 197, 358, 556, 759, 962, 1168, 1390, 1650, 1895, 2065, 2175, 2248, 2318, 2400, 2425, 2352, 2210, 2032, 1863, 1689, 1489, 1280, 1092, 928, 733, 499, 298, 151, 53, 10, 0, 0, 0, 0], 'num_def_loads': 3, 'nominal_power_of_deferrable_loads': [2150, 2000, 0], 'operating_timesteps_of_each_deferrable_load': [8, 2, 0], 'treat_deferrable_load_as_semi_cont': [False, False, False], 'set_deferrable_load_single_constant': [True, True, True], 'def_start_timestep': [-14, -2, 2], 'def_end_timestep': [10, 16, 16], 'def_current_state': [True, True, False], 'soc_init': 0.73, 'soc_final': 0.24, 'load_cost_forecast': [0.1511, 0.1511, 0.1511, 0.1511, 0.1534, 0.1534, 0.1845, 0.1845, 0.242, 0.242, 0.229, 0.229, 0.2548, 0.2548, 0.2781, 0.2781, 0.2696, 0.2696, 0.2638, 0.2638, 0.2564, 0.2564], 'prod_price_forecast': [-0.0091, -0.0091, -0.0091, -0.0091, -0.0068, -0.0068, 0.0225, 0.0225, 0.0768, 0.0768, 0.0645, 0.0645, 0.0888, 0.0888, 0.1108, 0.1108, 0.1028, 0.1028, 0.0973, 0.0973, 0.0903, 0.0903], 'alpha': 0.2, 'beta': 0.428, 'load_power_forecast': [0, 400, 1200, 900, 800, 500, 200, 200, 300, 200, 400, 300, 200, 800, 800, 400, 500, 400, 500, 0, 200, 500, 600, 400, 400, 500, 400, 400, 400, 500, 400, 600, 500, 600, 600, 400, 300, 300, 300, 400, 200, 500, 300, 300, 300, 400, 300, 200], 'weight_battery_charge': 0.005, 'weight_battery_discharge': 0.052, 'set_deferrable_startup_penalty': [10, 5, 5]}
[2025-07-19 13:15:01 +0200] [21] [INFO] >> Setting input data dict
[2025-07-19 13:15:01 +0200] [21] [INFO] Setting up needed data
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Initialized Optimization with retrieve_hass_conf: {'optimization_time_step': Timedelta('0 days 00:30:00'), 'historic_days_to_retrieve': 10, 'sensor_power_photovoltaics': 'sensor.inverter_ingangsvermogen', 'sensor_power_photovoltaics_forecast': 'sensor.p_pv_forecast', 'sensor_power_load_no_var_loads': 'sensor.power_load_no_var_loads', 'load_negative': False, 'set_zero_min': True, 'sensor_replace_zero': ['sensor.inverter_ingangsvermogen'], 'sensor_linear_interp': ['sensor.inverter_ingangsvermogen', 'sensor.power_load_no_var_loads'], 'method_ts_round': 'first', 'continual_publish': False, 'hass_url': 'http://supervisor/core/api', 'long_lived_token': 'b831d4028007f708c07528140a5b454a67afe558752f96782cb577fe1ac48c7d04ca414c245138d39c2eac88e9713d33f399fa1d7498a651', 'time_zone': <DstTzInfo 'Europe/Brussels' LMT+0:18:00 STD>, 'Latitude': 50.789456233171535, 'Longitude': 5.592577457427979, 'Altitude': 110}
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Optimization configuration: {'costfun': 'self-consumption', 'logging_level': 'DEBUG', 'set_use_pv': True, 'set_use_adjusted_pv': False, 'adjusted_pv_regression_model': 'LassoRegression', 'adjusted_pv_solar_elevation_threshold': 10, 'set_use_battery': True, 'number_of_deferrable_loads': 3, 'nominal_power_of_deferrable_loads': [2150, 2000, 0], 'minimum_power_of_deferrable_loads': [0, 0, 0, 0, 0], 'operating_hours_of_each_deferrable_load': [2, 2, 2, 2, 0], 'treat_deferrable_load_as_semi_cont': [False, False, False], 'set_deferrable_load_single_constant': [True, True, True], 'set_deferrable_startup_penalty': [10, 5, 5], 'delta_forecast_daily': Timedelta('1 days 00:00:00'), 'load_forecast_method': 'list', 'load_cost_forecast_method': 'list', 'load_peak_hours_cost': 0.1907, 'load_offpeak_hours_cost': 0.1419, 'production_price_forecast_method': 'list', 'photovoltaic_production_sell_price': 0.065, 'set_total_pv_sell': False, 'lp_solver': 'COIN_CMD', 'lp_solver_path': '/usr/bin/cbc', 'lp_solver_timeout': 45, 'num_threads': 0, 'set_nocharge_from_grid': False, 'set_nodischarge_to_grid': False, 'set_battery_dynamic': True, 'battery_dynamic_max': 0.85, 'battery_dynamic_min': -0.5, 'weight_battery_discharge': 0.052, 'weight_battery_charge': 0.005, 'weather_forecast_method': 'list', 'open_meteo_cache_max_age': 30, 'start_timesteps_of_each_deferrable_load': [-14, -2, 2], 'end_timesteps_of_each_deferrable_load': [10, 16, 16], 'load_peak_hour_periods': {'period_hp_1': [{'start': '08:00'}, {'end': '17:00'}], 'period_hp_2': [{'start': '08:00'}, {'end': '17:00'}]}, 'operating_timesteps_of_each_deferrable_load': [8, 2, 0], 'def_current_state': [True, True, False]}
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Plant configuration: {'maximum_power_from_grid': 4000, 'maximum_power_to_grid': 6000, 'pv_module_model': ['JA_Solar_JAM72S01_385_PR', 'JA_Solar_JAM72S01_385_PR', 'JA_Solar_JAM72S01_385_PR'], 'pv_inverter_model': ['Huawei_Technologies_Co___Ltd___SUN2000_9KTL_USL0__240V_', 'Huawei_Technologies_Co___Ltd___SUN2000_9KTL_USL0__240V_', 'Huawei_Technologies_Co___Ltd___SUN2000_9KTL_USL0__240V_'], 'surface_tilt': [35, 35, 15], 'surface_azimuth': [90, 270, 180], 'modules_per_string': [6, 6, 13], 'strings_per_inverter': [1, 1, 1], 'inverter_is_hybrid': True, 'compute_curtailment': True, 'battery_discharge_power_max': 5000, 'battery_charge_power_max': 5000, 'battery_discharge_efficiency': 1, 'battery_charge_efficiency': 0.95, 'battery_nominal_energy_capacity': 15000, 'battery_minimum_state_of_charge': 0.12, 'battery_maximum_state_of_charge': 1, 'battery_target_state_of_charge': 0.12}
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Solver configuration: lp_solver=COIN_CMD, lp_solver_path=/usr/bin/cbc
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Number of threads: 2
[2025-07-19 13:15:01 +0200] [21] [INFO] Retrieving weather forecast data using method = list
[2025-07-19 13:15:01 +0200] [21] [DEBUG] get_weather_forecast returning:
yhat
ts
2025-07-19 13:00:00+02:00 3194
2025-07-19 13:30:00+02:00 5304
2025-07-19 14:00:00+02:00 5169
2025-07-19 14:30:00+02:00 4791
2025-07-19 15:00:00+02:00 4331
2025-07-19 15:30:00+02:00 3836
2025-07-19 16:00:00+02:00 3334
2025-07-19 16:30:00+02:00 2852
2025-07-19 17:00:00+02:00 2384
2025-07-19 17:30:00+02:00 1942
2025-07-19 18:00:00+02:00 1478
2025-07-19 18:30:00+02:00 1009
2025-07-19 19:00:00+02:00 661
2025-07-19 19:30:00+02:00 433
2025-07-19 20:00:00+02:00 260
2025-07-19 20:30:00+02:00 131
2025-07-19 21:00:00+02:00 46
2025-07-19 21:30:00+02:00 9
2025-07-19 22:00:00+02:00 0
2025-07-19 22:30:00+02:00 0
2025-07-19 23:00:00+02:00 0
2025-07-19 23:30:00+02:00 0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] get_power_from_weather returning:
ts
2025-07-19 13:00:00+02:00 3194
2025-07-19 13:30:00+02:00 5304
2025-07-19 14:00:00+02:00 5169
2025-07-19 14:30:00+02:00 4791
2025-07-19 15:00:00+02:00 4331
2025-07-19 15:30:00+02:00 3836
2025-07-19 16:00:00+02:00 3334
2025-07-19 16:30:00+02:00 2852
2025-07-19 17:00:00+02:00 2384
2025-07-19 17:30:00+02:00 1942
2025-07-19 18:00:00+02:00 1478
2025-07-19 18:30:00+02:00 1009
2025-07-19 19:00:00+02:00 661
2025-07-19 19:30:00+02:00 433
2025-07-19 20:00:00+02:00 260
2025-07-19 20:30:00+02:00 131
2025-07-19 21:00:00+02:00 46
2025-07-19 21:30:00+02:00 9
2025-07-19 22:00:00+02:00 0
2025-07-19 22:30:00+02:00 0
2025-07-19 23:00:00+02:00 0
2025-07-19 23:30:00+02:00 0
dtype: int64
[2025-07-19 13:15:01 +0200] [21] [DEBUG] get_load_forecast returning:
2025-07-19 13:00:00+02:00 0
2025-07-19 13:30:00+02:00 400
2025-07-19 14:00:00+02:00 1200
2025-07-19 14:30:00+02:00 900
2025-07-19 15:00:00+02:00 800
2025-07-19 15:30:00+02:00 500
2025-07-19 16:00:00+02:00 200
2025-07-19 16:30:00+02:00 200
2025-07-19 17:00:00+02:00 300
2025-07-19 17:30:00+02:00 200
2025-07-19 18:00:00+02:00 400
2025-07-19 18:30:00+02:00 300
2025-07-19 19:00:00+02:00 200
2025-07-19 19:30:00+02:00 800
2025-07-19 20:00:00+02:00 800
2025-07-19 20:30:00+02:00 400
2025-07-19 21:00:00+02:00 500
2025-07-19 21:30:00+02:00 400
2025-07-19 22:00:00+02:00 500
2025-07-19 22:30:00+02:00 0
2025-07-19 23:00:00+02:00 200
2025-07-19 23:30:00+02:00 500
Name: yhat, dtype: int64
[2025-07-19 13:15:01 +0200] [21] [INFO] >> Performing naive MPC optimization...
[2025-07-19 13:15:01 +0200] [21] [INFO] Performing naive MPC optimization
[2025-07-19 13:15:01 +0200] [21] [DEBUG] get_load_cost_forecast returning:
P_PV_forecast P_load_forecast unit_load_cost
2025-07-19 13:00:00+02:00 3194 0 0.1511
2025-07-19 13:30:00+02:00 5304 400 0.1511
2025-07-19 14:00:00+02:00 5169 1200 0.1511
2025-07-19 14:30:00+02:00 4791 900 0.1511
2025-07-19 15:00:00+02:00 4331 800 0.1534
2025-07-19 15:30:00+02:00 3836 500 0.1534
2025-07-19 16:00:00+02:00 3334 200 0.1845
2025-07-19 16:30:00+02:00 2852 200 0.1845
2025-07-19 17:00:00+02:00 2384 300 0.2420
2025-07-19 17:30:00+02:00 1942 200 0.2420
2025-07-19 18:00:00+02:00 1478 400 0.2290
2025-07-19 18:30:00+02:00 1009 300 0.2290
2025-07-19 19:00:00+02:00 661 200 0.2548
2025-07-19 19:30:00+02:00 433 800 0.2548
2025-07-19 20:00:00+02:00 260 800 0.2781
2025-07-19 20:30:00+02:00 131 400 0.2781
2025-07-19 21:00:00+02:00 46 500 0.2696
2025-07-19 21:30:00+02:00 9 400 0.2696
2025-07-19 22:00:00+02:00 0 500 0.2638
2025-07-19 22:30:00+02:00 0 0 0.2638
2025-07-19 23:00:00+02:00 0 200 0.2564
2025-07-19 23:30:00+02:00 0 500 0.2564
[2025-07-19 13:15:01 +0200] [21] [DEBUG] get_prod_price_forecast returning:
P_PV_forecast ... unit_prod_price
2025-07-19 13:00:00+02:00 3194 ... -0.0091
2025-07-19 13:30:00+02:00 5304 ... -0.0091
2025-07-19 14:00:00+02:00 5169 ... -0.0091
2025-07-19 14:30:00+02:00 4791 ... -0.0091
2025-07-19 15:00:00+02:00 4331 ... -0.0068
2025-07-19 15:30:00+02:00 3836 ... -0.0068
2025-07-19 16:00:00+02:00 3334 ... 0.0225
2025-07-19 16:30:00+02:00 2852 ... 0.0225
2025-07-19 17:00:00+02:00 2384 ... 0.0768
2025-07-19 17:30:00+02:00 1942 ... 0.0768
2025-07-19 18:00:00+02:00 1478 ... 0.0645
2025-07-19 18:30:00+02:00 1009 ... 0.0645
2025-07-19 19:00:00+02:00 661 ... 0.0888
2025-07-19 19:30:00+02:00 433 ... 0.0888
2025-07-19 20:00:00+02:00 260 ... 0.1108
2025-07-19 20:30:00+02:00 131 ... 0.1108
2025-07-19 21:00:00+02:00 46 ... 0.1028
2025-07-19 21:30:00+02:00 9 ... 0.1028
2025-07-19 22:00:00+02:00 0 ... 0.0973
2025-07-19 22:30:00+02:00 0 ... 0.0973
2025-07-19 23:00:00+02:00 0 ... 0.0903
2025-07-19 23:30:00+02:00 0 ... 0.0903
[22 rows x 4 columns]
[2025-07-19 13:15:01 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.73, Final SOC: 0.24
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 0 is standard/non-thermal.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 0: Using total timesteps constraint: 8
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 0: Standard load constraints set.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -14 --> 10
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 10
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 1 is standard/non-thermal.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 1: Using total timesteps constraint: 2
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Load 1: Standard load constraints set.
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: -2 --> 16
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 0 --> 16
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 2 --> 16
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 2 --> 16
[2025-07-19 13:15:01 +0200] [21] [INFO] Status: Infeasible
[2025-07-19 13:15:01 +0200] [21] [INFO] Total value of the Cost function = -1.77
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.73, Final SOC: 0.24
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load operating hours: [0, 0, 0, 0, 0]
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load timesteps: [8, 2, 0]
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load start timesteps: [-14, -2, 2]
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Deferrable load end timesteps: [10, 16, 16]
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Selected cost function type: self-consumption
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Solver selected: COIN_CMD
[2025-07-19 13:15:01 +0200] [21] [INFO] Optimization status: Infeasible
[2025-07-19 13:15:01 +0200] [21] [INFO] Publishing data to HASS instance
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_pv_forecast = 3194
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_pv_forecast to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_load_forecast = 0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_load_forecast to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_pv_curtailment = 0.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_pv_curtailment to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_hybrid_inverter = 2150.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_hybrid_inverter to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_deferrable0 = 2150.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_deferrable0 to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_deferrable1 = 0.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_deferrable1 to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_deferrable2 = 0.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_deferrable2 to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_batt_forecast = -1044.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_batt_forecast to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_soc_batt_forecast = 76.31
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_soc_batt_forecast to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_grid_forecast = 0.0
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_p_grid_forecast to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_total_cost_fun_value = 1.19
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_total_cost_fun_value to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_optim_status = Infeasible
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_optim_status to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_unit_load_cost = 0.1511
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_unit_load_cost to json file
[2025-07-19 13:15:01 +0200] [21] [INFO] Successfully posted to sensor.mpc_unit_prod_price = -0.0091
[2025-07-19 13:15:01 +0200] [21] [DEBUG] Saved sensor.mpc_unit_prod_price to json file
[2025-07-19 13:15:02 +0200] [21] [INFO] >> Obtaining params:
[2025-07-19 13:15:02 +0200] [21] [INFO] Passed runtime parameters: {'publish_prefix': 'mpc_'}
[2025-07-19 13:15:02 +0200] [21] [INFO] >> Setting input data dict
[2025-07-19 13:15:02 +0200] [21] [INFO] Setting up needed data
[2025-07-19 13:15:02 +0200] [21] [DEBUG] Initialized Optimization with retrieve_hass_conf: {'optimization_time_step': Timedelta('0 days 00:30:00'), 'historic_days_to_retrieve': 10, 'sensor_power_photovoltaics': 'sensor.inverter_ingangsvermogen', 'sensor_power_photovoltaics_forecast': 'sensor.p_pv_forecast', 'sensor_power_load_no_var_loads': 'sensor.power_load_no_var_loads', 'load_negative': False, 'set_zero_min': True, 'sensor_replace_zero': ['sensor.inverter_ingangsvermogen'], 'sensor_linear_interp': ['sensor.inverter_ingangsvermogen', 'sensor.power_load_no_var_loads'], 'method_ts_round': 'first', 'continual_publish': False, 'hass_url': 'http://supervisor/core/api', 'long_lived_token': 'b831d4028007f708c07528140a5b454a67afe558752f96782cb577fe1ac48c7d04ca414c245138d39c2eac88e9713d33f399fa1d7498a651', 'time_zone': <DstTzInfo 'Europe/Brussels' LMT+0:18:00 STD>, 'Latitude': 50.789456233171535, 'Longitude': 5.592577457427979, 'Altitude': 110}
[2025-07-19 13:15:02 +0200] [21] [DEBUG] Optimization configuration: {'costfun': 'self-consumption', 'logging_level': 'DEBUG', 'set_use_pv': True, 'set_use_adjusted_pv': False, 'adjusted_pv_regression_model': 'LassoRegression', 'adjusted_pv_solar_elevation_threshold': 10, 'set_use_battery': True, 'number_of_deferrable_loads': 5, 'nominal_power_of_deferrable_loads': [2150, 2000, 3000, 3000, 3000], 'minimum_power_of_deferrable_loads': [0, 0, 0, 0, 0], 'operating_hours_of_each_deferrable_load': [2, 2, 2, 2, 0], 'treat_deferrable_load_as_semi_cont': [False, False, False, False, False], 'set_deferrable_load_single_constant': [True, True, True, False, False], 'set_deferrable_startup_penalty': [3, 5, 5, 0, 0], 'delta_forecast_daily': Timedelta('1 days 00:00:00'), 'load_forecast_method': 'naive', 'load_cost_forecast_method': 'hp_hc_periods', 'load_peak_hours_cost': 0.1907, 'load_offpeak_hours_cost': 0.1419, 'production_price_forecast_method': 'constant', 'photovoltaic_production_sell_price': 0.065, 'set_total_pv_sell': False, 'lp_solver': 'COIN_CMD', 'lp_solver_path': '/usr/bin/cbc', 'lp_solver_timeout': 45, 'num_threads': 0, 'set_nocharge_from_grid': False, 'set_nodischarge_to_grid': False, 'set_battery_dynamic': True, 'battery_dynamic_max': 0.85, 'battery_dynamic_min': -0.5, 'weight_battery_discharge': 0.05, 'weight_battery_charge': 0.01, 'weather_forecast_method': 'open-meteo', 'open_meteo_cache_max_age': 30, 'start_timesteps_of_each_deferrable_load': [0, 0, 0, 0, 0], 'end_timesteps_of_each_deferrable_load': [0, 0, 0, 0, 0], 'load_peak_hour_periods': {'period_hp_1': [{'start': '08:00'}, {'end': '17:00'}], 'period_hp_2': [{'start': '08:00'}, {'end': '17:00'}]}}
[2025-07-19 13:15:02 +0200] [21] [DEBUG] Plant configuration: {'maximum_power_from_grid': 4000, 'maximum_power_to_grid': 6000, 'pv_module_model': ['JA_Solar_JAM72S01_385_PR', 'JA_Solar_JAM72S01_385_PR', 'JA_Solar_JAM72S01_385_PR'], 'pv_inverter_model': ['Huawei_Technologies_Co___Ltd___SUN2000_9KTL_USL0__240V_', 'Huawei_Technologies_Co___Ltd___SUN2000_9KTL_USL0__240V_', 'Huawei_Technologies_Co___Ltd___SUN2000_9KTL_USL0__240V_'], 'surface_tilt': [35, 35, 15], 'surface_azimuth': [90, 270, 180], 'modules_per_string': [6, 6, 13], 'strings_per_inverter': [1, 1, 1], 'inverter_is_hybrid': True, 'compute_curtailment': True, 'battery_discharge_power_max': 5000, 'battery_charge_power_max': 5000, 'battery_discharge_efficiency': 1, 'battery_charge_efficiency': 0.95, 'battery_nominal_energy_capacity': 15000, 'battery_minimum_state_of_charge': 0.12, 'battery_maximum_state_of_charge': 1, 'battery_target_state_of_charge': 0.12}
[2025-07-19 13:15:02 +0200] [21] [DEBUG] Solver configuration: lp_solver=COIN_CMD, lp_solver_path=/usr/bin/cbc
[2025-07-19 13:15:02 +0200] [21] [DEBUG] Number of threads: 2
[2025-07-19 13:15:02 +0200] [21] [INFO] >> Publishing data...
[2025-07-19 13:15:02 +0200] [21] [INFO] Publishing data to HASS instance
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_optim_status = Infeasible
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_deferrable2 = 0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_unit_load_cost = 0.1511
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_soc_batt_forecast = 76.31
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_grid_forecast = 0.0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_total_cost_fun_value = 1.19
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_batt_forecast = -1044.0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_load_forecast = 0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_pv_curtailment = 0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_hybrid_inverter = 2150.0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_deferrable0 = 2150
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_unit_prod_price = -0.0091
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_deferrable1 = 0.0
[2025-07-19 13:15:02 +0200] [21] [INFO] Successfully posted to sensor.mpc_p_pv_forecast = 3194
[2025-07-19 13:15:06 +0200] [21] [INFO] EMHASS server online, serving index.html...
I think all is in there: passed runtime parameters + config. I canât find the issue, if I use operating_hours_of_each_deferrable_load with these settings, all runs well. 30 min optimization, mpc running every 5 min.
My (uneducated guess) is that the negative start-timestamp could be causing this. Looking at the help files it looks like a negative value automatically gets replaced with a 0 and basically means start this period now. Maybe the system is unable to get all your deferrable loads between the time you run it and the end period. Are you always supplying negative values, or are they dynamically trying to show that it was supposed to start -14 timeslots (7 hrs) ago?
The way I do it is always start my loads at 0 or a positive value, and finish at 0 or a positive value. The end time is calculated at each run and gradually reduces as I get closer to the end time. Though I do use operating_hours_of_each_deferrable_load rather than operating_timesteps_of_each_deferrable_load
Another idea is that it looks like you have 3 deferrable loads, but in some of the supplied data you include 5x values (i.e. 'operating_hours_of_each_deferrable_load': [2, 2, 2, 2, 0]). Maybe try dropping those down to just the 3âŚ
I tried reducing deferrables from 5 in the config to 3, no result.
Below you can see an experiment with âhoursâ setting and âtimestepsâ setting for load 1. Running window of 3h (6 timesteps)
Only thing I changed was passing operating_timesteps_of_each_deferrable_load in stead of operating_hours_of_each_deferrable_load.
Timesteps give infeasible, Hours give optimal.
It seems negative are not a problem, as you said, it gets corrected, but maybe I am wrong here.
[2025-07-21 09:48:03 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.29, Final SOC: 0.24
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -6 --> 18
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 18
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Load 1 is standard/non-thermal.
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Load 1: Using total timesteps constraint: 6
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Load 1: Standard load constraints set.
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: 2 --> 10
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 2 --> 10
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 10 --> 16
[2025-07-21 09:48:03 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 10 --> 16
[2025-07-21 09:48:03 +0200] [21] [INFO] Status: Infeasible
[2025-07-21 09:50:02 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.3, Final SOC: 0.24
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -6 --> 18
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 18
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Load 1 is standard/non-thermal.
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Load 1: Using total hours constraint: 3
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Load 1: Standard load constraints set.
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: 2 --> 10
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 2 --> 10
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 10 --> 16
[2025-07-21 09:50:02 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 10 --> 16
[2025-07-21 09:50:02 +0200] [21] [INFO] Status: Optimal
Timesteps is a relatively new feature, so maybe it hasnât had much robust testingâŚ
Do you have operating hours set in your EMHASS config and are setting operating timesteps in the runtime command?
If so I think you need to set operating hours in EMHASS config to 0.
I set operating hours to zero now and to 3 deferrables in EMHASS config(which are the deferrables I have)
'number_of_deferrable_loads': 3, 'nominal_power_of_deferrable_loads': [2150, 2000, 3000], 'minimum_power_of_deferrable_loads': [0, 0, 0], 'operating_hours_of_each_deferrable_load': [0, 0, 0]
With this result:
[2025-07-21 12:17:59 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.66, Final SOC: 0.24
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -12 --> 12
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 12
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Load 1 is standard/non-thermal.
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Load 1: Using total timesteps constraint: 6
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Load 1: Standard load constraints set.
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: 0 --> 10
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 0 --> 10
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 4 --> 10
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 4 --> 10
[2025-07-21 12:17:59 +0200] [21] [INFO] Status: Infeasible
[2025-07-21 12:17:59 +0200] [21] [INFO] Total value of the Cost function = 1.58
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.66, Final SOC: 0.24
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load operating hours: [0, 0, 0]
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load timesteps: [0, 6, 0]
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load start timesteps: [-12, 0, 4]
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Deferrable load end timesteps: [12, 10, 10]
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Selected cost function type: self-consumption
[2025-07-21 12:17:59 +0200] [21] [DEBUG] Solver selected: COIN_CMD
[2025-07-21 12:17:59 +0200] [21] [INFO] Optimization status: Infeasible
And this is with âhourâ steps:
[2025-07-21 12:20:01 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.66, Final SOC: 0.24
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -12 --> 12
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 12
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Load 1 is standard/non-thermal.
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Load 1: Using total hours constraint: 3
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Load 1: Standard load constraints set.
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: 0 --> 10
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 0 --> 10
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 4 --> 10
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 4 --> 10
[2025-07-21 12:20:01 +0200] [21] [INFO] Status: Optimal
[2025-07-21 12:20:01 +0200] [21] [INFO] Total value of the Cost function = 1.61
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.66, Final SOC: 0.24
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load operating hours: [0, 3, 0]
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load timesteps: None
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load start timesteps: [-12, 0, 4]
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Deferrable load end timesteps: [12, 10, 10]
[2025-07-21 12:20:01 +0200] [21] [DEBUG] Selected cost function type: self-consumption
And this is the result with âtimestepsâ but no deferrable scheduled:
[2025-07-21 12:27:19 +0200] [21] [INFO] Perform an iteration of a naive MPC controller
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.67, Final SOC: 0.24
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Processing deferrable load 0
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load 0: Proposed optimization window: -12 --> 12
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load 0: Validated optimization window: 0 --> 12
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Processing deferrable load 1
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load 1: Proposed optimization window: 0 --> 10
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load 1: Validated optimization window: 0 --> 10
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Processing deferrable load 2
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load 2: Proposed optimization window: 4 --> 10
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load 2: Validated optimization window: 4 --> 10
[2025-07-21 12:27:19 +0200] [21] [INFO] Status: Optimal
[2025-07-21 12:27:19 +0200] [21] [INFO] Total value of the Cost function = 1.35
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Battery usage enabled. Initial SOC: 0.67, Final SOC: 0.24
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load operating hours: [0, 0, 0]
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load timesteps: [0, 0, 0]
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load start timesteps: [-12, 0, 4]
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Deferrable load end timesteps: [12, 10, 10]
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Selected cost function type: self-consumption
[2025-07-21 12:27:19 +0200] [21] [DEBUG] Solver selected: COIN_CMD
[2025-07-21 12:27:19 +0200] [21] [INFO] Optimization status: Optimal
Dear Community,
First of all thank you for this wonderful project.
I work with emhass since one year and a half for optimization of my thermodynamic water heater and it work very well.
Now i want to include a second system my dishwasher. For this i have created an other mpc (test_mpc) and i encountered this error only on the test-mpc
[2025-07-24 11:54:23 +0200] [25] [DEBUG] Solver configuration: lp_solver=default, lp_solver_path=empty
[2025-07-24 11:54:23 +0200] [25] [DEBUG] Number of threads: 4
[2025-07-24 11:54:23 +0200] [25] [INFO] Retrieve hass get data method initiatedâŚ
[2025-07-24 11:54:23 +0200] [25] [DEBUG] prepare_data self.var_list=[âsensor.power_load_no_var_loadsâ, âsensor.onduleur_huawei_active_power_in_wattâ]
[2025-07-24 11:54:23 +0200] [25] [DEBUG] prepare_data var_load=sensor.power_load_no_var_loads
[2025-07-24 11:54:23 +0200] [25] [DEBUG] prepare_data load_negative=False
[2025-07-24 11:54:23 +0200] [25] [DEBUG] prepare_data set_zero_min=True
[2025-07-24 11:54:23 +0200] [25] [DEBUG] prepare_data var_replace_zero=[âsensor.power_load_no_var_loadsâ, âsensor.onduleur_huawei_active_power_in_wattâ]
[2025-07-24 11:54:23 +0200] [25] [DEBUG] prepare_data var_interp=[âsensor.power_load_no_var_loadsâ, âsensor.onduleur_huawei_active_power_in_wattâ]
[2025-07-24 11:54:23 +0200] [25] [INFO] Retrieving weather forecast data using method = solar.forecast
[2025-07-24 11:54:26 +0200] [25] [ERROR] Exception on /action/naive-mpc-optim [POST]
Traceback (most recent call last):
File â/app/.venv/lib/python3.12/site-packages/flask/app.pyâ, line 1511, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File â/app/.venv/lib/python3.12/site-packages/flask/app.pyâ, line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File â/app/.venv/lib/python3.12/site-packages/flask/app.pyâ, line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File â/app/.venv/lib/python3.12/site-packages/flask/app.pyâ, line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File â/app/src/emhass/web_server.pyâ, line 411, in action_call
input_data_dict = set_input_data_dict(
^^^^^^^^^^^^^^^^^^^^
File â/app/src/emhass/command_line.pyâ, line 378, in set_input_data_dict
df_weather = fcst.get_weather_forecast(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File â/app/src/emhass/forecast.pyâ, line 562, in get_weather_forecast
âtsâ: list(data_raw[âresultâ][âwattsâ].keys()),
It result that the timeline seems shorten compare to what i ask does anyone has an idea ?
I give you some screenshot about the result of mpc and test_mpc
Dear @markpurcell
Could you please share to me how you manage to have mpc and mpc test working together ?
Thanks a lot



