EMHASS: An Energy Management for Home Assistant

I finaly have some time now to try to set up EMHASS on my HA, but am getting lost in the configuration screen.

Neither can i find a youtube tutorial. Or a clear explanation of where i can retreive every value.
Isn’t there a manual or youtubevideo i can watch? I couldn’t find it.

Yes EMHASS doco is here → Energy Management for Home Assistant — emhass 0.16.2 documentation

Best to ask for help in this forum I guess.

1 Like

Hi Mark, I have seen some of you posts on here showing the dashboards and energy management automation that you have set up which are all very impressive. I am just starting off with HA and Amber. I have 10 KW, 50 KWh battery, solar and EV. I would like to optimise the charging and discharging of the battery to the grid based on the energy prices from Amber and AEMO forecasts. Would you be able to share some of the codes for the dashboards you have set up for you automations and how you have set up EMHASS to work with Amber and AEMO pricing. Anything you can share to help me get started would be much appreciated :slightly_smiling_face:

1 Like

I’ve just started so my configuration may be seriously wrong, but it appears to have generated the result that seemingly reasonable/logical. However, the MPC will only run when maximum_power_from_grid is NOT 0 and must have at least 1000W. Otherwise I got the “infeasible” error and I have no idea what or where went wrong. @davidusb, really keen if you can help or assist in validating if there is anything wrong with my config or point me the in right direction to resolve this.

'costfun': 'profit', 
'prediction_horizon': 576, 
'optimization_time_step': 5, 
'delta_forecast_daily': 2, 
'set_use_pv': True, 
'set_use_battery': True,
'inverter_is_hybrid': True, 
'number_of_deferrable_loads': 1, 
'set_nodischarge_to_grid': False, 
'logging_level': 'debug', 
'lp_solver_timeout': 45, 
'compute_curtailment': True, 
'nominal_power_of_deferrable_loads': [5000], 
'operating_hours_of_each_deferrable_load': [4], 
'start_timesteps_of_each_deferrable_load': [-148], 
'end_timesteps_of_each_deferrable_load': [-28], 
'treat_deferrable_load_as_semi_cont': [False], 
'set_deferrable_load_single_constant': [True]
'weight_battery_charge': 0.1,
'weight_battery_discharge': 0.1, 
'battery_minimum_state_of_charge': 0.5, 
'battery_nominal_energy_capacity': 40300, 
'battery_charge_power_max': 21000, 
'battery_discharge_power_max': 24000, 
'maximum_power_from_grid': **1000,** 
'maximum_power_to_grid': 5000, 
'inverter_ac_output_max': 9999, 
'inverter_ac_input_max': 9999,
'soc_init': 0.796,
'soc_final': 0.5, 
'load_cost_forecast': {'2026-02-18T00:00:00+11:00': 0.2001, '2026-02-18T00:05:00+11:00': 0.2001, '2026-02-18T00:10:00+11:00': 0.2001, '2026-02-18T00:15:00+11:00': 0.2001, '2026-02-18T00:20:00+11:00': 0.2001, '2026-02-18T00:25:00+11:00': 0.2001, '2026-02-18T00:30:00+11:00': 0.2001, '2026-02-18T00:35:00+11:00': 0.2001, '2026-02-18T00:40:00+11:00': 0.2001, '2026-02-18T00:45:00+11:00': 0.2001, '2026-02-18T00:50:00+11:00': 0.2001, '2026-02-18T00:55:00+11:00': 0.2001, '2026-02-18T01:00:00+11:00': 0.2001, '2026-02-18T01:05:00+11:00': 0.2001, '2026-02-18T01:10:00+11:00': 0.2001, '2026-02-18T01:15:00+11:00': 0.2001, '2026-02-18T01:20:00+11:00': 0.2001, '2026-02-18T01:25:00+11:00': 0.2001, '2026-02-18T01:30:00+11:00': 0.2001, '2026-02-18T01:35:00+11:00': 0.2001, '2026-02-18T01:40:00+11:00': 0.2001, '2026-02-18T01:45:00+11:00': 0.2001, '2026-02-18T01:50:00+11:00': 0.2001, '2026-02-18T01:55:00+11:00': 0.2001, '2026-02-18T02:00:00+11:00': 0.2001, '2026-02-18T02:05:00+11:00': 0.2001, '2026-02-18T02:10:00+11:00': 0.2001, '2026-02-18T02:15:00+11:00': 0.2001, '2026-02-18T02:20:00+11:00': 0.2001, '2026-02-18T02:25:00+11:00': 0.2001, '2026-02-18T02:30:00+11:00': 0.2001, '2026-02-18T02:35:00+11:00': 0.2001, '2026-02-18T02:40:00+11:00': 0.2001, '2026-02-18T02:45:00+11:00': 0.2001, '2026-02-18T02:50:00+11:00': 0.2001, '2026-02-18T02:55:00+11:00': 0.2001, '2026-02-18T03:00:00+11:00': 0.2001, '2026-02-18T03:05:00+11:00': 0.2001, '2026-02-18T03:10:00+11:00': 0.2001, '2026-02-18T03:15:00+11:00': 0.2001, '2026-02-18T03:20:00+11:00': 0.2001, '2026-02-18T03:25:00+11:00': 0.2001, '2026-02-18T03:30:00+11:00': 0.2001, '2026-02-18T03:35:00+11:00': 0.2001, '2026-02-18T03:40:00+11:00': 0.2001, '2026-02-18T03:45:00+11:00': 0.2001, '2026-02-18T03:50:00+11:00': 0.2001, '2026-02-18T03:55:00+11:00': 0.2001, '2026-02-18T04:00:00+11:00': 0.2001, '2026-02-18T04:05:00+11:00': 0.2001, '2026-02-18T04:10:00+11:00': 0.2001, '2026-02-18T04:15:00+11:00': 0.2001, '2026-02-18T04:20:00+11:00': 0.2001, '2026-02-18T04:25:00+11:00': 0.2001, '2026-02-18T04:30:00+11:00': 0.2001, '2026-02-18T04:35:00+11:00': 0.2001, '2026-02-18T04:40:00+11:00': 0.2001, '2026-02-18T04:45:00+11:00': 0.2001, '2026-02-18T04:50:00+11:00': 0.2001, '2026-02-18T04:55:00+11:00': 0.2001, '2026-02-18T05:00:00+11:00': 0.2001, '2026-02-18T05:05:00+11:00': 0.2001, '2026-02-18T05:10:00+11:00': 0.2001, '2026-02-18T05:15:00+11:00': 0.2001, '2026-02-18T05:20:00+11:00': 0.2001, '2026-02-18T05:25:00+11:00': 0.2001, '2026-02-18T05:30:00+11:00': 0.2001, '2026-02-18T05:35:00+11:00': 0.2001, '2026-02-18T05:40:00+11:00': 0.2001, '2026-02-18T05:45:00+11:00': 0.2001, '2026-02-18T05:50:00+11:00': 0.2001, '2026-02-18T05:55:00+11:00': 0.2001, '2026-02-18T06:00:00+11:00': 0.3001, '2026-02-18T06:05:00+11:00': 0.3001, '2026-02-18T06:10:00+11:00': 0.3001, '2026-02-18T06:15:00+11:00': 0.3001, '2026-02-18T06:20:00+11:00': 0.3001, '2026-02-18T06:25:00+11:00': 0.3001, '2026-02-18T06:30:00+11:00': 0.3001, '2026-02-18T06:35:00+11:00': 0.3001, '2026-02-18T06:40:00+11:00': 0.3001, '2026-02-18T06:45:00+11:00': 0.3001, '2026-02-18T06:50:00+11:00': 0.3001, '2026-02-18T06:55:00+11:00': 0.3001, '2026-02-18T07:00:00+11:00': 0.3001, '2026-02-18T07:05:00+11:00': 0.3001, '2026-02-18T07:10:00+11:00': 0.3001, '2026-02-18T07:15:00+11:00': 0.3001, '2026-02-18T07:20:00+11:00': 0.3001, '2026-02-18T07:25:00+11:00': 0.3001, '2026-02-18T07:30:00+11:00': 0.3001, '2026-02-18T07:35:00+11:00': 0.3001, '2026-02-18T07:40:00+11:00': 0.3001, '2026-02-18T07:45:00+11:00': 0.3001, '2026-02-18T07:50:00+11:00': 0.3001, '2026-02-18T07:55:00+11:00': 0.3001, '2026-02-18T08:00:00+11:00': 0.3001, '2026-02-18T08:05:00+11:00': 0.3001, '2026-02-18T08:10:00+11:00': 0.3001, '2026-02-18T08:15:00+11:00': 0.3001, '2026-02-18T08:20:00+11:00': 0.3001, '2026-02-18T08:25:00+11:00': 0.3001, '2026-02-18T08:30:00+11:00': 0.3001, '2026-02-18T08:35:00+11:00': 0.3001, '2026-02-18T08:40:00+11:00': 0.3001, '2026-02-18T08:45:00+11:00': 0.3001, '2026-02-18T08:50:00+11:00': 0.3001, '2026-02-18T08:55:00+11:00': 0.3001, '2026-02-18T09:00:00+11:00': 0.3001, '2026-02-18T09:05:00+11:00': 0.3001, '2026-02-18T09:10:00+11:00': 0.3001, '2026-02-18T09:15:00+11:00': 0.3001, '2026-02-18T09:20:00+11:00': 0.3001, '2026-02-18T09:25:00+11:00': 0.3001, '2026-02-18T09:30:00+11:00': 0.3001, '2026-02-18T09:35:00+11:00': 0.3001, '2026-02-18T09:40:00+11:00': 0.3001, '2026-02-18T09:45:00+11:00': 0.3001, '2026-02-18T09:50:00+11:00': 0.3001, '2026-02-18T09:55:00+11:00': 0.3001, '2026-02-18T10:00:00+11:00': 0.3001, '2026-02-18T10:05:00+11:00': 0.3001, '2026-02-18T10:10:00+11:00': 0.3001, '2026-02-18T10:15:00+11:00': 0.3001, '2026-02-18T10:20:00+11:00': 0.3001, '2026-02-18T10:25:00+11:00': 0.3001, '2026-02-18T10:30:00+11:00': 0.3001, '2026-02-18T10:35:00+11:00': 0.3001, '2026-02-18T10:40:00+11:00': 0.3001, '2026-02-18T10:45:00+11:00': 0.3001, '2026-02-18T10:50:00+11:00': 0.3001, '2026-02-18T10:55:00+11:00': 0.3001, '2026-02-18T11:00:00+11:00': 0.3001, '2026-02-18T11:05:00+11:00': 0.3001, '2026-02-18T11:10:00+11:00': 0.3001, '2026-02-18T11:15:00+11:00': 0.3001, '2026-02-18T11:20:00+11:00': 0.3001, '2026-02-18T11:25:00+11:00': 0.3001, '2026-02-18T11:30:00+11:00': 0.3001, '2026-02-18T11:35:00+11:00': 0.3001, '2026-02-18T11:40:00+11:00': 0.3001, '2026-02-18T11:45:00+11:00': 0.3001, '2026-02-18T11:50:00+11:00': 0.3001, '2026-02-18T11:55:00+11:00': 0.3001, '2026-02-18T12:00:00+11:00': 0.3001, '2026-02-18T12:05:00+11:00': 0.3001, '2026-02-18T12:10:00+11:00': 0.3001, '2026-02-18T12:15:00+11:00': 0.3001, '2026-02-18T12:20:00+11:00': 0.3001, '2026-02-18T12:25:00+11:00': 0.3001, '2026-02-18T12:30:00+11:00': 0.3001, '2026-02-18T12:35:00+11:00': 0.3001, '2026-02-18T12:40:00+11:00': 0.3001, '2026-02-18T12:45:00+11:00': 0.3001, '2026-02-18T12:50:00+11:00': 0.3001, '2026-02-18T12:55:00+11:00': 0.3001, '2026-02-18T13:00:00+11:00': 0.3001, '2026-02-18T13:05:00+11:00': 0.3001, '2026-02-18T13:10:00+11:00': 0.3001, '2026-02-18T13:15:00+11:00': 0.3001, '2026-02-18T13:20:00+11:00': 0.3001, '2026-02-18T13:25:00+11:00': 0.3001, '2026-02-18T13:30:00+11:00': 0.3001, '2026-02-18T13:35:00+11:00': 0.3001, '2026-02-18T13:40:00+11:00': 0.3001, '2026-02-18T13:45:00+11:00': 0.3001, '2026-02-18T13:50:00+11:00': 0.3001, '2026-02-18T13:55:00+11:00': 0.3001, '2026-02-18T14:00:00+11:00': 0.3001, '2026-02-18T14:05:00+11:00': 0.3001, '2026-02-18T14:10:00+11:00': 0.3001, '2026-02-18T14:15:00+11:00': 0.3001, '2026-02-18T14:20:00+11:00': 0.3001, '2026-02-18T14:25:00+11:00': 0.3001, '2026-02-18T14:30:00+11:00': 0.3001, '2026-02-18T14:35:00+11:00': 0.3001, '2026-02-18T14:40:00+11:00': 0.3001, '2026-02-18T14:45:00+11:00': 0.3001, '2026-02-18T14:50:00+11:00': 0.3001, '2026-02-18T14:55:00+11:00': 0.3001, '2026-02-18T15:00:00+11:00': 0.3001, '2026-02-18T15:05:00+11:00': 0.3001, '2026-02-18T15:10:00+11:00': 0.3001, '2026-02-18T15:15:00+11:00': 0.3001, '2026-02-18T15:20:00+11:00': 0.3001, '2026-02-18T15:25:00+11:00': 0.3001, '2026-02-18T15:30:00+11:00': 0.3001, '2026-02-18T15:35:00+11:00': 0.3001, '2026-02-18T15:40:00+11:00': 0.3001, '2026-02-18T15:45:00+11:00': 0.3001, '2026-02-18T15:50:00+11:00': 0.3001, '2026-02-18T15:55:00+11:00': 0.3001, '2026-02-18T16:00:00+11:00': 0.3001, '2026-02-18T16:05:00+11:00': 0.3001, '2026-02-18T16:10:00+11:00': 0.3001, '2026-02-18T16:15:00+11:00': 0.3001, '2026-02-18T16:20:00+11:00': 0.3001, '2026-02-18T16:25:00+11:00': 0.3001, '2026-02-18T16:30:00+11:00': 0.3001, '2026-02-18T16:35:00+11:00': 0.3001, '2026-02-18T16:40:00+11:00': 0.3001, '2026-02-18T16:45:00+11:00': 0.3001, '2026-02-18T16:50:00+11:00': 0.3001, '2026-02-18T16:55:00+11:00': 0.3001, '2026-02-18T17:00:00+11:00': 0.3001, '2026-02-18T17:05:00+11:00': 0.3001, '2026-02-18T17:10:00+11:00': 0.3001, '2026-02-18T17:15:00+11:00': 0.3001, '2026-02-18T17:20:00+11:00': 0.3001, '2026-02-18T17:25:00+11:00': 0.3001, '2026-02-18T17:30:00+11:00': 0.3001, '2026-02-18T17:35:00+11:00': 0.3001, '2026-02-18T17:40:00+11:00': 0.3001, '2026-02-18T17:45:00+11:00': 0.3001, '2026-02-18T17:50:00+11:00': 0.3001, '2026-02-18T17:55:00+11:00': 0.3001, '2026-02-18T18:00:00+11:00': 0.3001, '2026-02-18T18:05:00+11:00': 0.3001, '2026-02-18T18:10:00+11:00': 0.3001, '2026-02-18T18:15:00+11:00': 0.3001, '2026-02-18T18:20:00+11:00': 0.3001, '2026-02-18T18:25:00+11:00': 0.3001, '2026-02-18T18:30:00+11:00': 0.3001, '2026-02-18T18:35:00+11:00': 0.3001, '2026-02-18T18:40:00+11:00': 0.3001, '2026-02-18T18:45:00+11:00': 0.3001, '2026-02-18T18:50:00+11:00': 0.3001, '2026-02-18T18:55:00+11:00': 0.3001, '2026-02-18T19:00:00+11:00': 0.3001, '2026-02-18T19:05:00+11:00': 0.3001, '2026-02-18T19:10:00+11:00': 0.3001, '2026-02-18T19:15:00+11:00': 0.3001, '2026-02-18T19:20:00+11:00': 0.3001, '2026-02-18T19:25:00+11:00': 0.3001, '2026-02-18T19:30:00+11:00': 0.3001, '2026-02-18T19:35:00+11:00': 0.3001, '2026-02-18T19:40:00+11:00': 0.3001, '2026-02-18T19:45:00+11:00': 0.3001, '2026-02-18T19:50:00+11:00': 0.3001, '2026-02-18T19:55:00+11:00': 0.3001, '2026-02-18T20:00:00+11:00': 0.3001, '2026-02-18T20:05:00+11:00': 0.3001, '2026-02-18T20:10:00+11:00': 0.3001, '2026-02-18T20:15:00+11:00': 0.3001, '2026-02-18T20:20:00+11:00': 0.3001, '2026-02-18T20:25:00+11:00': 0.3001, '2026-02-18T20:30:00+11:00': 0.3001, '2026-02-18T20:35:00+11:00': 0.3001, '2026-02-18T20:40:00+11:00': 0.3001, '2026-02-18T20:45:00+11:00': 0.3001, '2026-02-18T20:50:00+11:00': 0.3001, '2026-02-18T20:55:00+11:00': 0.3001, '2026-02-18T21:00:00+11:00': 0.3001, '2026-02-18T21:05:00+11:00': 0.3001, '2026-02-18T21:10:00+11:00': 0.3001, '2026-02-18T21:15:00+11:00': 0.3001, '2026-02-18T21:20:00+11:00': 0.3001, '2026-02-18T21:25:00+11:00': 0.3001, '2026-02-18T21:30:00+11:00': 0.3001, '2026-02-18T21:35:00+11:00': 0.3001, '2026-02-18T21:40:00+11:00': 0.3001, '2026-02-18T21:45:00+11:00': 0.3001, '2026-02-18T21:50:00+11:00': 0.3001, '2026-02-18T21:55:00+11:00': 0.3001, '2026-02-18T22:00:00+11:00': 0.3001, '2026-02-18T22:05:00+11:00': 0.3001, '2026-02-18T22:10:00+11:00': 0.3001, '2026-02-18T22:15:00+11:00': 0.3001, '2026-02-18T22:20:00+11:00': 0.3001, '2026-02-18T22:25:00+11:00': 0.3001, '2026-02-18T22:30:00+11:00': 0.3001, '2026-02-18T22:35:00+11:00': 0.3001, '2026-02-18T22:40:00+11:00': 0.3001, '2026-02-18T22:45:00+11:00': 0.3001, '2026-02-18T22:50:00+11:00': 0.3001, '2026-02-18T22:55:00+11:00': 0.3001, '2026-02-18T23:00:00+11:00': 0.3001, '2026-02-18T23:05:00+11:00': 0.3001, '2026-02-18T23:10:00+11:00': 0.3001, '2026-02-18T23:15:00+11:00': 0.3001, '2026-02-18T23:20:00+11:00': 0.3001, '2026-02-18T23:25:00+11:00': 0.3001, '2026-02-18T23:30:00+11:00': 0.3001, '2026-02-18T23:35:00+11:00': 0.3001, '2026-02-18T23:40:00+11:00': 0.3001, '2026-02-18T23:45:00+11:00': 0.3001, '2026-02-18T23:50:00+11:00': 0.3001, '2026-02-18T23:55:00+11:00': 0.3001, '2026-02-19T00:00:00+11:00': 0.2001, '2026-02-19T00:05:00+11:00': 0.2001, '2026-02-19T00:10:00+11:00': 0.2001, '2026-02-19T00:15:00+11:00': 0.2001, '2026-02-19T00:20:00+11:00': 0.2001, '2026-02-19T00:25:00+11:00': 0.2001, '2026-02-19T00:30:00+11:00': 0.2001, '2026-02-19T00:35:00+11:00': 0.2001, '2026-02-19T00:40:00+11:00': 0.2001, '2026-02-19T00:45:00+11:00': 0.2001, '2026-02-19T00:50:00+11:00': 0.2001, '2026-02-19T00:55:00+11:00': 0.2001, '2026-02-19T01:00:00+11:00': 0.2001, '2026-02-19T01:05:00+11:00': 0.2001, '2026-02-19T01:10:00+11:00': 0.2001, '2026-02-19T01:15:00+11:00': 0.2001, '2026-02-19T01:20:00+11:00': 0.2001, '2026-02-19T01:25:00+11:00': 0.2001, '2026-02-19T01:30:00+11:00': 0.2001, '2026-02-19T01:35:00+11:00': 0.2001, '2026-02-19T01:40:00+11:00': 0.2001, '2026-02-19T01:45:00+11:00': 0.2001, '2026-02-19T01:50:00+11:00': 0.2001, '2026-02-19T01:55:00+11:00': 0.2001, '2026-02-19T02:00:00+11:00': 0.2001, '2026-02-19T02:05:00+11:00': 0.2001, '2026-02-19T02:10:00+11:00': 0.2001, '2026-02-19T02:15:00+11:00': 0.2001, '2026-02-19T02:20:00+11:00': 0.2001, '2026-02-19T02:25:00+11:00': 0.2001, '2026-02-19T02:30:00+11:00': 0.2001, '2026-02-19T02:35:00+11:00': 0.2001, '2026-02-19T02:40:00+11:00': 0.2001, '2026-02-19T02:45:00+11:00': 0.2001, '2026-02-19T02:50:00+11:00': 0.2001, '2026-02-19T02:55:00+11:00': 0.2001, '2026-02-19T03:00:00+11:00': 0.2001, '2026-02-19T03:05:00+11:00': 0.2001, '2026-02-19T03:10:00+11:00': 0.2001, '2026-02-19T03:15:00+11:00': 0.2001, '2026-02-19T03:20:00+11:00': 0.2001, '2026-02-19T03:25:00+11:00': 0.2001, '2026-02-19T03:30:00+11:00': 0.2001, '2026-02-19T03:35:00+11:00': 0.2001, '2026-02-19T03:40:00+11:00': 0.2001, '2026-02-19T03:45:00+11:00': 0.2001, '2026-02-19T03:50:00+11:00': 0.2001, '2026-02-19T03:55:00+11:00': 0.2001, '2026-02-19T04:00:00+11:00': 0.2001, '2026-02-19T04:05:00+11:00': 0.2001, '2026-02-19T04:10:00+11:00': 0.2001, '2026-02-19T04:15:00+11:00': 0.2001, '2026-02-19T04:20:00+11:00': 0.2001, '2026-02-19T04:25:00+11:00': 0.2001, '2026-02-19T04:30:00+11:00': 0.2001, '2026-02-19T04:35:00+11:00': 0.2001, '2026-02-19T04:40:00+11:00': 0.2001, '2026-02-19T04:45:00+11:00': 0.2001, '2026-02-19T04:50:00+11:00': 0.2001, '2026-02-19T04:55:00+11:00': 0.2001, '2026-02-19T05:00:00+11:00': 0.2001, '2026-02-19T05:05:00+11:00': 0.2001, '2026-02-19T05:10:00+11:00': 0.2001, '2026-02-19T05:15:00+11:00': 0.2001, '2026-02-19T05:20:00+11:00': 0.2001, '2026-02-19T05:25:00+11:00': 0.2001, '2026-02-19T05:30:00+11:00': 0.2001, '2026-02-19T05:35:00+11:00': 0.2001, '2026-02-19T05:40:00+11:00': 0.2001, '2026-02-19T05:45:00+11:00': 0.2001, '2026-02-19T05:50:00+11:00': 0.2001, '2026-02-19T05:55:00+11:00': 0.2001, '2026-02-19T06:00:00+11:00': 0.3001, '2026-02-19T06:05:00+11:00': 0.3001, '2026-02-19T06:10:00+11:00': 0.3001, '2026-02-19T06:15:00+11:00': 0.3001, '2026-02-19T06:20:00+11:00': 0.3001, '2026-02-19T06:25:00+11:00': 0.3001, '2026-02-19T06:30:00+11:00': 0.3001, '2026-02-19T06:35:00+11:00': 0.3001, '2026-02-19T06:40:00+11:00': 0.3001, '2026-02-19T06:45:00+11:00': 0.3001, '2026-02-19T06:50:00+11:00': 0.3001, '2026-02-19T06:55:00+11:00': 0.3001, '2026-02-19T07:00:00+11:00': 0.3001, '2026-02-19T07:05:00+11:00': 0.3001, '2026-02-19T07:10:00+11:00': 0.3001, '2026-02-19T07:15:00+11:00': 0.3001, '2026-02-19T07:20:00+11:00': 0.3001, '2026-02-19T07:25:00+11:00': 0.3001, '2026-02-19T07:30:00+11:00': 0.3001, '2026-02-19T07:35:00+11:00': 0.3001, '2026-02-19T07:40:00+11:00': 0.3001, '2026-02-19T07:45:00+11:00': 0.3001, '2026-02-19T07:50:00+11:00': 0.3001, '2026-02-19T07:55:00+11:00': 0.3001, '2026-02-19T08:00:00+11:00': 0.3001, '2026-02-19T08:05:00+11:00': 0.3001, '2026-02-19T08:10:00+11:00': 0.3001, '2026-02-19T08:15:00+11:00': 0.3001, '2026-02-19T08:20:00+11:00': 0.3001, '2026-02-19T08:25:00+11:00': 0.3001, '2026-02-19T08:30:00+11:00': 0.3001, '2026-02-19T08:35:00+11:00': 0.3001, '2026-02-19T08:40:00+11:00': 0.3001, '2026-02-19T08:45:00+11:00': 0.3001, '2026-02-19T08:50:00+11:00': 0.3001, '2026-02-19T08:55:00+11:00': 0.3001, '2026-02-19T09:00:00+11:00': 0.3001, '2026-02-19T09:05:00+11:00': 0.3001, '2026-02-19T09:10:00+11:00': 0.3001, '2026-02-19T09:15:00+11:00': 0.3001, '2026-02-19T09:20:00+11:00': 0.3001, '2026-02-19T09:25:00+11:00': 0.3001, '2026-02-19T09:30:00+11:00': 0.3001, '2026-02-19T09:35:00+11:00': 0.3001, '2026-02-19T09:40:00+11:00': 0.3001, '2026-02-19T09:45:00+11:00': 0.3001, '2026-02-19T09:50:00+11:00': 0.3001, '2026-02-19T09:55:00+11:00': 0.3001, '2026-02-19T10:00:00+11:00': 0.3001, '2026-02-19T10:05:00+11:00': 0.3001, '2026-02-19T10:10:00+11:00': 0.3001, '2026-02-19T10:15:00+11:00': 0.3001, '2026-02-19T10:20:00+11:00': 0.3001, '2026-02-19T10
:25:00+11:00': 0.3001, '2026-02-19T10:30:00+11:00': 0.3001, '2026-02-19T10:35:00+11:00': 0.3001, '2026-02-19T10:40:00+11:00': 0.3001, '2026-02-19T10:45:00+11:00': 0.3001, '2026-02-19T10:50:00+11:00': 0.3001, '2026-02-19T10:55:00+11:00': 0.3001, '2026-02-19T11:00:00+11:00': 0.3001, '2026-02-19T11:05:00+11:00': 0.3001, '2026-02-19T11:10:00+11:00': 0.3001, '2026-02-19T11:15:00+11:00': 0.3001, '2026-02-19T11:20:00+11:00': 0.3001, '2026-02-19T11:25:00+11:00': 0.3001, '2026-02-19T11:30:00+11:00': 0.3001, '2026-02-19T11:35:00+11:00': 0.3001, '2026-02-19T11:40:00+11:00': 0.3001, '2026-02-19T11:45:00+11:00': 0.3001, '2026-02-19T11:50:00+11:00': 0.3001, '2026-02-19T11:55:00+11:00': 0.3001, '2026-02-19T12:00:00+11:00': 0.3001, '2026-02-19T12:05:00+11:00': 0.3001, '2026-02-19T12:10:00+11:00': 0.3001, '2026-02-19T12:15:00+11:00': 0.3001, '2026-02-19T12:20:00+11:00': 0.3001, '2026-02-19T12:25:00+11:00': 0.3001, '2026-02-19T12:30:00+11:00': 0.3001, '2026-02-19T12:35:00+11:00': 0.3001, '2026-02-19T12:40:00+11:00': 0.3001, '2026-02-19T12:45:00+11:00': 0.3001, '2026-02-19T12:50:00+11:00': 0.3001, '2026-02-19T12:55:00+11:00': 0.3001, '2026-02-19T13:00:00+11:00': 0.3001, '2026-02-19T13:05:00+11:00': 0.3001, '2026-02-19T13:10:00+11:00': 0.3001, '2026-02-19T13:15:00+11:00': 0.3001, '2026-02-19T13:20:00+11:00': 0.3001, '2026-02-19T13:25:00+11:00': 0.3001, '2026-02-19T13:30:00+11:00': 0.3001, '2026-02-19T13:35:00+11:00': 0.3001, '2026-02-19T13:40:00+11:00': 0.3001, '2026-02-19T13:45:00+11:00': 0.3001, '2026-02-19T13:50:00+11:00': 0.3001, '2026-02-19T13:55:00+11:00': 0.3001, '2026-02-19T14:00:00+11:00': 0.3001, '2026-02-19T14:05:00+11:00': 0.3001, '2026-02-19T14:10:00+11:00': 0.3001, '2026-02-19T14:15:00+11:00': 0.3001, '2026-02-19T14:20:00+11:00': 0.3001, '2026-02-19T14:25:00+11:00': 0.3001, '2026-02-19T14:30:00+11:00': 0.3001, '2026-02-19T14:35:00+11:00': 0.3001, '2026-02-19T14:40:00+11:00': 0.3001, '2026-02-19T14:45:00+11:00': 0.3001, '2026-02-19T14:50:00+11:00': 0.3001, '2026-02-19T14:55:00+11:00': 0.3001, '2026-02-19T15:00:00+11:00': 0.3001, '2026-02-19T15:05:00+11:00': 0.3001, '2026-02-19T15:10:00+11:00': 0.3001, '2026-02-19T15:15:00+11:00': 0.3001, '2026-02-19T15:20:00+11:00': 0.3001, '2026-02-19T15:25:00+11:00': 0.3001, '2026-02-19T15:30:00+11:00': 0.3001, '2026-02-19T15:35:00+11:00': 0.3001, '2026-02-19T15:40:00+11:00': 0.3001, '2026-02-19T15:45:00+11:00': 0.3001, '2026-02-19T15:50:00+11:00': 0.3001, '2026-02-19T15:55:00+11:00': 0.3001, '2026-02-19T16:00:00+11:00': 0.3001, '2026-02-19T16:05:00+11:00': 0.3001, '2026-02-19T16:10:00+11:00': 0.3001, '2026-02-19T16:15:00+11:00': 0.3001, '2026-02-19T16:20:00+11:00': 0.3001, '2026-02-19T16:25:00+11:00': 0.3001, '2026-02-19T16:30:00+11:00': 0.3001, '2026-02-19T16:35:00+11:00': 0.3001, '2026-02-19T16:40:00+11:00': 0.3001, '2026-02-19T16:45:00+11:00': 0.3001, '2026-02-19T16:50:00+11:00': 0.3001, '2026-02-19T16:55:00+11:00': 0.3001, '2026-02-19T17:00:00+11:00': 0.3001, '2026-02-19T17:05:00+11:00': 0.3001, '2026-02-19T17:10:00+11:00': 0.3001, '2026-02-19T17:15:00+11:00': 0.3001, '2026-02-19T17:20:00+11:00': 0.3001, '2026-02-19T17:25:00+11:00': 0.3001, '2026-02-19T17:30:00+11:00': 0.3001, '2026-02-19T17:35:00+11:00': 0.3001, '2026-02-19T17:40:00+11:00': 0.3001, '2026-02-19T17:45:00+11:00': 0.3001, '2026-02-19T17:50:00+11:00': 0.3001, '2026-02-19T17:55:00+11:00': 0.3001, '2026-02-19T18:00:00+11:00': 0.3001, '2026-02-19T18:05:00+11:00': 0.3001, '2026-02-19T18:10:00+11:00': 0.3001, '2026-02-19T18:15:00+11:00': 0.3001, '2026-02-19T18:20:00+11:00': 0.3001, '2026-02-19T18:25:00+11:00': 0.3001, '2026-02-19T18:30:00+11:00': 0.3001, '2026-02-19T18:35:00+11:00': 0.3001, '2026-02-19T18:40:00+11:00': 0.3001, '2026-02-19T18:45:00+11:00': 0.3001, '2026-02-19T18:50:00+11:00': 0.3001, '2026-02-19T18:55:00+11:00': 0.3001, '2026-02-19T19:00:00+11:00': 0.3001, '2026-02-19T19:05:00+11:00': 0.3001, '2026-02-19T19:10:00+11:00': 0.3001, '2026-02-19T19:15:00+11:00': 0.3001, '2026-02-19T19:20:00+11:00': 0.3001, '2026-02-19T19:25:00+11:00': 0.3001, '2026-02-19T19:30:00+11:00': 0.3001, '2026-02-19T19:35:00+11:00': 0.3001, '2026-02-19T19:40:00+11:00': 0.3001, '2026-02-19T19:45:00+11:00': 0.3001, '2026-02-19T19:50:00+11:00': 0.3001, '2026-02-19T19:55:00+11:00': 0.3001, '2026-02-19T20:00:00+11:00': 0.3001, '2026-02-19T20:05:00+11:00': 0.3001, '2026-02-19T20:10:00+11:00': 0.3001, '2026-02-19T20:15:00+11:00': 0.3001, '2026-02-19T20:20:00+11:00': 0.3001, '2026-02-19T20:25:00+11:00': 0.3001, '2026-02-19T20:30:00+11:00': 0.3001, '2026-02-19T20:35:00+11:00': 0.3001, '2026-02-19T20:40:00+11:00': 0.3001, '2026-02-19T20:45:00+11:00': 0.3001, '2026-02-19T20:50:00+11:00': 0.3001, '2026-02-19T20:55:00+11:00': 0.3001, '2026-02-19T21:00:00+11:00': 0.3001, '2026-02-19T21:05:00+11:00': 0.3001, '2026-02-19T21:10:00+11:00': 0.3001, '2026-02-19T21:15:00+11:00': 0.3001, '2026-02-19T21:20:00+11:00': 0.3001, '2026-02-19T21:25:00+11:00': 0.3001, '2026-02-19T21:30:00+11:00': 0.3001, '2026-02-19T21:35:00+11:00': 0.3001, '2026-02-19T21:40:00+11:00': 0.3001, '2026-02-19T21:45:00+11:00': 0.3001, '2026-02-19T21:50:00+11:00': 0.3001, '2026-02-19T21:55:00+11:00': 0.3001, '2026-02-19T22:00:00+11:00': 0.3001, '2026-02-19T22:05:00+11:00': 0.3001, '2026-02-19T22:10:00+11:00': 0.3001, '2026-02-19T22:15:00+11:00': 0.3001, '2026-02-19T22:20:00+11:00': 0.3001, '2026-02-19T22:25:00+11:00': 0.3001, '2026-02-19T22:30:00+11:00': 0.3001, '2026-02-19T22:35:00+11:00': 0.3001, '2026-02-19T22:40:00+11:00': 0.3001, '2026-02-19T22:45:00+11:00': 0.3001, '2026-02-19T22:50:00+11:00': 0.3001, '2026-02-19T22:55:00+11:00': 0.3001, '2026-02-19T23:00:00+11:00': 0.3001, '2026-02-19T23:05:00+11:00': 0.3001, '2026-02-19T23:10:00+11:00': 0.3001, '2026-02-19T23:15:00+11:00': 0.3001, '2026-02-19T23:20:00+11:00': 0.3001, '2026-02-19T23:25:00+11:00': 0.3001, '2026-02-19T23:30:00+11:00': 0.3001, '2026-02-19T23:35:00+11:00': 0.3001, '2026-02-19T23:40:00+11:00': 0.3001, '2026-02-19T23:45:00+11:00': 0.3001, '2026-02-19T23:50:00+11:00': 0.3001, '2026-02-19T23:55:00+11:00': 0.3001}, 'prod_price_forecast': {'2026-02-18T00:00:00+11:00': 0.1, '2026-02-19T00:00:00+11:00': 0.1}
'pv_power_forecast': {'2026-02-18T22:20:51+11:00': 0, '2026-02-18T22:30:00+11:00': 0, '2026-02-18T23:00:00+11:00': 0, '2026-02-18T23:30:00+11:00': 0, '2026-02-19T00:00:00+11:00': 0, '2026-02-19T00:30:00+11:00': 0, '2026-02-19T01:00:00+11:00': 0, '2026-02-19T01:30:00+11:00': 0, '2026-02-19T02:00:00+11:00': 0, '2026-02-19T02:30:00+11:00': 0, '2026-02-19T03:00:00+11:00': 0, '2026-02-19T03:30:00+11:00': 0, '2026-02-19T04:00:00+11:00': 0, '2026-02-19T04:30:00+11:00': 0, '2026-02-19T05:00:00+11:00': 0, '2026-02-19T05:30:00+11:00': 0, '2026-02-19T06:00:00+11:00': 0, '2026-02-19T06:30:00+11:00': 0, '2026-02-19T07:00:00+11:00': 237, '2026-02-19T07:30:00+11:00': 1324, '2026-02-19T08:00:00+11:00': 2709, '2026-02-19T08:30:00+11:00': 3944, '2026-02-19T09:00:00+11:00': 5038, '2026-02-19T09:30:00+11:00': 5979, '2026-02-19T10:00:00+11:00': 6661, '2026-02-19T10:30:00+11:00': 7206, '2026-02-19T11:00:00+11:00': 7628, '2026-02-19T11:30:00+11:00': 7955, '2026-02-19T12:00:00+11:00': 8102, '2026-02-19T12:30:00+11:00': 8001, '2026-02-19T13:00:00+11:00': 7946, '2026-02-19T13:30:00+11:00': 7845, '2026-02-19T14:00:00+11:00': 7764, '2026-02-19T14:30:00+11:00': 7646, '2026-02-19T15:00:00+11:00': 7329
'load_power_forecast': {'2026-02-18T22:20:51+11:00': 2235, '2026-02-18T23:00:00+11:00': 1935, '2026-02-19T00:00:00+11:00': 1872, '2026-02-19T01:00:00+11:00': 1628, '2026-02-19T02:00:00+11:00': 1500, '2026-02-19T03:00:00+11:00': 373, '2026-02-19T04:00:00+11:00': 361, '2026-02-19T05:00:00+11:00': 292, '2026-02-19T06:00:00+11:00': 251, '2026-02-19T07:00:00+11:00': 818, '2026-02-19T08:00:00+11:00': 892, '2026-02-19T09:00:00+11:00': 269, '2026-02-19T10:00:00+11:00': 275, '2026-02-19T11:00:00+11:00': 286, '2026-02-19T12:00:00+11:00': 1400, '2026-02-19T13:00:00+11:00': 5713, '2026-02-19T14:00:00+11:00': 5213, '2026-02-19T15:00:00+11:00': 4772, '2026-02-19T16:00:00+11:00': 1172, '2026-02-19T17:00:00+11:00': 4521, '2026-02-19T18:00:00+11:00': 2153, '2026-02-19T19:00:00+11:00': 1920, '2026-02-19T20:00:00+11:00': 1509, '2026-02-19T21:00:00+11:00': 1681, '2026-02-19T22:00:00+11:00': 1113, '2026-02-19T23:00:00+11:00': 545, '2026-02-20T00:00:00+11:00': 577, '2026-02-20T01:00:00+11:00': 919, '2026-02-20T02:00:00+11:00': 677, '2026-02-20T03:00:00+11:00': 324, '2026-02-20T04:00:00+11:00': 301, '2026-02-20T05:00:00+11:00': 299, '2026-02-20T06:00:00+11:00': 677, '2026-02-20T07:00:00+11:00': 1730, '2026-02-20T08:00:00+11:00': 333, '2026-02-20T09:00:00+11:00': 327, '2026-02-20T10:00:00+11:00': 301, '2026-02-20T11:00:00+11:00': 365, '2026-02-20T12:00:00+11:00': 338, '2026-02-20T13:00:00+11:00': 273, '2026-02-20T14:00:00+11:00': 258, '2026-02-20T15:00:00+11:00': 276, '2026-02-20T16:00:00+11:00': 317, '2026-02-20T17:00:00+11:00': 3527, '2026-02-20T18:00:00+11:00': 3367, '2026-02-20T19:00:00+11:00': 1974, '2026-02-20T20:00:00+11:00': 2242, '2026-02-20T21:00:00+11:00': 2152}}

When maximum_power_from_grid is set to 0, below are the messages I get and the optimisation is not complete (no data published)

[2026-02-18 22:19:21,795] INFO in command_line: Setting up needed data
[2026-02-18 22:19:21,944] INFO in retrieve_hass: get HA config from rest api.
[2026-02-18 22:19:21,956] INFO in forecast: Retrieving weather forecast data using method = list
[2026-02-18 22:19:21,965] INFO in web_server:  >> Performing naive-mpc-optim...
[2026-02-18 22:19:21,965] INFO in command_line: Performing naive MPC optimization
[2026-02-18 22:19:22,079] INFO in optimization: Perform an iteration of a naive MPC controller
[2026-02-18 22:19:22,086] INFO in optimization: Building CVXPY problem structure...
[2026-02-18 22:19:31,781] WARNING in optimization: **Optimization failed with status: 'infeasible'. Retrying with relaxed constraints (Continuous LP)...**
[2026-02-18 22:19:31,787] INFO in optimization: Solving relaxed problem (LP)...
[2026-02-18 22:19:32,224] ERROR in optimization: Relaxed optimization also failed with status: infeasible
[2026-02-18 22:19:32,225] WARNING in optimization: Cost function cannot be evaluated or Infeasible/Unbounded


[2026-02-18 22:19:32,546] INFO in web_server:  >> Setting input data dict
[2026-02-18 22:19:32,546] INFO in command_line: Setting up needed data
[2026-02-18 22:19:32,557] INFO in retrieve_hass: get HA config from rest api.
[2026-02-18 22:19:32,568] INFO in web_server:  >> Publishing data...
[2026-02-18 22:19:32,568] INFO in command_line: Publishing data to HASS instance
[2026-02-18 22:19:32,581] ERROR in app: Exception on request POST /action/publish-data
Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3641, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pandas/_libs/index.pyx", line 168, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 197, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7668, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7676, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'P_PV'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1464, in handle_request
    return await self.full_dispatch_request(request_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1502, in full_dispatch_request
    result = await self.handle_user_exception(error)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1059, in handle_user_exception
    raise error
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1500, in full_dispatch_request
    result = await self.dispatch_request(request_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1597, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/web_server.py", line 652, in action_call
    msg, status = await _handle_action_dispatch(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/web_server.py", line 506, in _handle_action_dispatch
    _ = await publish_data(input_data_dict, logger)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/command_line.py", line 2034, in publish_data
    cols_published.extend(await _publish_standard_forecasts(ctx, opt_res_latest))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/command_line.py", line 1731, in _publish_standard_forecasts
    opt_res_latest["P_PV"],
    ~~~~~~~~~~~~~~^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/pandas/core/frame.py", line 4378, in __getitem__
    indexer = self.columns.get_loc(key)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3648, in get_loc
    raise KeyError(key) from err
KeyError: 'P_PV'

This might help my configuration

Hi! After several months of a working day-ahead optimization, after udate suddenly is infeasible. Same result when test with runtime “dummy values”. Any help appreciated. Filed an issue in the github aswell: Infeasible after update of EMHASS · Issue #731 · davidusb-geek/emhass · GitHub

Dear community!

I’ve just release v0.17.0 :partying_face:

A small warning with this new release.
:warning: POSSIBLE BREAKING CHANGE: HA Add-on File Management

This release updates how EMHASS handles file management within Home Assistant, aligning with the new HA standard of using the dedicated /addon_configs folder for user-facing configuration files.

  • What changed: Configuration and data files have been migrated to the new addon_configs directory structure.
  • Why it might break your setup: If you are an advanced user who has written custom shell commands, external scripts, or backup automations that point strictly to the old hardcoded /share/emhass or /config directory paths, those paths will likely fail after this update.
  • Action Required: Please review any custom automations or scripts that read from or write to EMHASS files directly and update the paths to reflect the new /addon_configs/ location.
3 Likes

… Also…

I’ve created this new HACS project where I share this realization of a Solar Diverter or Solar Router.

I’ve built this myself at home and it has been working perfectly for several months now.

Cheers! :tada:

1 Like

https://emhass.readthedocs.io/en/latest/publish_data.html

reading through the publish data, it seems like the senso.total_cost_profit_value doesn’t publish at all for me. All the other sensors get published bar this. Anyone else having the same?

Problem solved. A change in powercalculations of house load caused it to breake. Had nothing to do with EMHASS. Took a while to figure out. My bad more or less…

Hi!

First of all, I’d like to thank @davidusb for this great piece of software. I’ve been increasing my use of EMHASS gradually over the past couple of months. I started with manually running a day-ahead pass in January and then manually configuring my battery charging periods, and manually enabling/disabling the battery’s self-consumption. Since then I’ve added automatically enabling/disabling the battery’s self-consumption, MPC runs, and tomorrow I want to test automatically disabling battery charging if EMHASS decides I should export (I don’t want to force-discharge yet, that’s a next step).

Anyway, I’m using EMHASS 0.17, but the following issue also happened with previous release before I upgraded today: I wonder why EMHASS is not planning to charge the battery more tomorrow (using solar energy) and then discharge it during peak hours (e.g. at 17h45). Instead, it’s sending the energy directly on the grid when it gets produced, at a much lower price. There’s of course overhead in storing it into the battery and taking it out again, but not that much? (I set my battery charge/discharge efficiency both to 0.975, and inverter DC<->AC efficiency both to 0.96).

I have these settings as well:

  • “set_nodischarge_to_grid”: false
  • “weight_battery_discharge”: 0

As I’m a new user, I can only attach one picture. So I put the graphs and table in one :grimacing: (this is a 3-day-window MPC run)

Hi all. Since upgrading to v0.17.0 the “battery_target_state_of_charge” parameter seems to be not working for me. My day ahead optimisations seem to be ending at 94% despite being set at other percentages. Have tried upddating config as well as by setting the parameter via the API call. Has been a little while since I have upgraded so not sure if it is the latest version or a recent version that has changed the behaviour. Hoping to see if others are having a similar issue (or a solution) before raising it as a bug. Thanks.

UPDATE: I’ve reverted back to v0.16.2 and it works fine, so thinking something must have changed in v0.17.0. Just strange if nobody else has noticed by now.

Some extra information:

I’ve noticed that this happens as soon as the pv forecasts for the current timestamp turn to 0. Related, the “replace NaNs with zeroes” setting seems to be failing, regardless of what sensor I supply to sensor_power_photovoltaics_forecast and sensor_replace_zero. I’ve tried both sensor.p_pv_forecast (using OpenMeteo as the provider in EMHASS) and sensor.power_production_now_2 (the latter is the current production sensor of my OpenMeteo integration).

See the failure here:

[2026-03-03 19:53:10,748] INFO in web_server: EMHASS server online, serving index.html...
[2026-03-03 19:53:12,992] INFO in web_server: serving configuration.html...
[2026-03-03 19:53:13,090] DEBUG in web_server: Obtaining current saved parameters as config
[2026-03-03 19:53:13,095] INFO in utils: Obtaining parameters from config.json:
[2026-03-03 19:53:13,100] DEBUG in utils: Converting param to config
[2026-03-03 19:57:21,966] INFO in web_server:  >> Obtaining params: 
[2026-03-03 19:57:21,974] INFO in web_server: Passed runtime parameters: {'number_of_deferrable_loads': 0,
'battery_charge_power_max': 3500,
'optimization_time_step': 15,
'sensor_power_photovoltaics': 'sensor.pvtotal_power',
'sensor_power_load_no_var_loads': 'sensor.total_power_load_in_watts',
'method_ts_round': 'first',
'use_websocket': False,
'model_type': 'ml_load_forecast_var_loads_included',
'prediction_horizon': 288,
'load_cost_forecast':
{'2026-03-03T18:30:00+00:00': 0.298,
'2026-03-03T18:45:00+00:00': 0.264,
...
 '2026-03-08T18:30:00+00:00': 0.282},
''prod_price_forecast':
{'2026-03-03T18:30:00+00:00': 0.14,
'2026-03-03T18:45:00+00:00': 0.108,
...
'2026-03-08T18:30:00+00:00': 0.125},
'soc_init': 0.77}
[2026-03-03 19:57:21,976] INFO in web_server:  >> Setting input data dict
[2026-03-03 19:57:21,977] INFO in command_line: Setting up needed data
[2026-03-03 19:57:21,998] WARNING in utils: Passed soc_final=0.1 is lower than soc_min=0.2, setting soc_final=soc_min
[2026-03-03 19:57:22,150] DEBUG in retrieve_hass: Websocket integration disabled, using Home Assistant API
[2026-03-03 19:57:22,151] DEBUG in retrieve_hass: InfluxDB integration disabled, using Home Assistant API
[2026-03-03 19:57:22,152] INFO in retrieve_hass: get HA config from rest api.
[2026-03-03 19:57:22,182] DEBUG in command_line: OptimizationCache HIT: Reusing cached optimization object (age=561.5s) - warm-start enabled
[2026-03-03 19:57:22,185] INFO in retrieve_hass: Using REST API for data retrieval
[2026-03-03 19:57:22,186] INFO in retrieve_hass: Retrieve hass get data method initiated...
[2026-03-03 19:57:23,004] DEBUG in retrieve_hass: prepare_data self.var_list=['sensor.total_power_load_in_watts', 'sensor.pvtotal_power']
[2026-03-03 19:57:23,005] DEBUG in retrieve_hass: prepare_data var_load=sensor.total_power_load_in_watts
[2026-03-03 19:57:23,006] DEBUG in retrieve_hass: Sensors in 'sensor_replace_zero' not found in data: ['sensor.p_pv_forecast']
[2026-03-03 19:57:23,010] DEBUG in retrieve_hass: prepare_data var_list updated after rename: ['sensor.total_power_load_in_watts_positive', 'sensor.pvtotal_power']
[2026-03-03 19:57:23,020] INFO in forecast: Retrieving weather forecast data using method = open-meteo
[2026-03-03 19:57:23,021] INFO in forecast: Loading existing cached Open-Meteo JSON file: /data/cached-open-meteo-forecast-b.json
[2026-03-03 19:57:23,026] INFO in forecast: The cached Open-Meteo JSON file is recent (age=9m, max_age=30m)
[2026-03-03 19:57:23,136] DEBUG in forecast: get_weather_forecast returning:
                           temp_air  relative_humidity  ...  dhi  dni
2026-03-03 19:45:00+01:00      12.4                 85  ...  0.0  0.0
2026-03-03 20:00:00+01:00      12.1                 85  ...  0.0  0.0
2026-03-03 20:15:00+01:00      11.8                 85  ...  0.0  0.0
2026-03-03 20:30:00+01:00      11.5                 85  ...  0.0  0.0
2026-03-03 20:45:00+01:00      11.3                 85  ...  0.0  0.0
...                             ...                ...  ...  ...  ...
2026-03-06 18:30:00+01:00      13.8                 77  ...  0.0  0.0
2026-03-06 18:45:00+01:00      13.3                 76  ...  0.0  0.0
2026-03-06 19:00:00+01:00      12.9                 77  ...  0.0  0.0
2026-03-06 19:15:00+01:00      12.7                 77  ...  0.0  0.0
2026-03-06 19:30:00+01:00      12.5                 78  ...  0.0  0.0
[288 rows x 8 columns]
/app/.venv/lib/python3.12/site-packages/scipy/optimize/_chandrupatla.py:437: RuntimeWarning:
invalid value encountered in divide
[2026-03-03 19:57:25,420] ERROR in app: Exception on request POST /action/naive-mpc-optim
Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1464, in handle_request
    return await self.full_dispatch_request(request_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1502, in full_dispatch_request
    result = await self.handle_user_exception(error)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1059, in handle_user_exception
    raise error
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1500, in full_dispatch_request
    result = await self.dispatch_request(request_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/quart/app.py", line 1597, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/web_server.py", line 633, in action_call
    input_data_dict = await set_input_data_dict(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/command_line.py", line 1078, in set_input_data_dict
    result = await _prepare_naive_mpc_optim(ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/command_line.py", line 799, in _prepare_naive_mpc_optim
    p_pv_forecast, df_weather = await _get_naive_mpc_pv_forecast(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/command_line.py", line 773, in _get_naive_mpc_pv_forecast
    p_pv_forecast = ctx.fcst.get_power_from_weather(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/forecast.py", line 820, in get_power_from_weather
    p_pv_forecast = Forecast.get_mix_forecast(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/emhass/forecast.py", line 658, in get_mix_forecast
    df_forecast.iloc[0] = int(round(first_fcst))
                              ^^^^^^^^^^^^^^^^^
ValueError: cannot convert float NaN to integer

In particular, note this:

[2026-03-03 19:57:23,006] DEBUG in retrieve_hass: Sensors in 'sensor_replace_zero' not found in data: ['sensor.p_pv_forecast']

It happens both with successful (current pv forecast != 0) and unsuccessful runs, but it presumably only matters when the current pv forecast is in fact 0. I’ve tried both with websocket and rest, and even tried manually constructing the url that I think emhass is using based on reading the source code (example ), and the output there looks fine.

Looking back through the logs, the same issue also happened in 0.16.2. So right now I’m running my MPC only from sunrise to sunset :sweat_smile:

On the plus side, those runs do work correctly with “set_nodischarge_to_grid” disabled (so correctly discharging to the grid when opportune). Also, day-ahead optimizations don’t suffer from this issue, only the MPC one does.

Since upgrading to v0.17.0 the “battery_target_state_of_charge” parameter seems to be not working for me.

I’ve noticed the same just now with a day-ahead optimization. I’ve changed my battery_target_state_of_charge to 0.77, but it keeps running with 0.1, which is a setting I used yesterday. I verified that my /addon_configs/5b918bf2_emhass/config.json has the correct value (0.77).

I can also confirm that downgrading to 0.16.2 fixes it. I guess it’s an issue related to the config file location moving (it’s perhaps saving in the new location and fetching from the old one for that setting?)

Hi all.
I thought I’d ask here before creating a feature request for EMHASS.
I’m using EMHASS extensively for battery optimization and thermal loads, and it makes all the difference for my solar plant with battery. I’m incredibly grateful for @davidusb and all co-developers for creating and maintaining EMHASS.

Now, what I don’t really understand is why I have to have a set battery SOC at the end of my optimization window when in reality I don’t care and it doesn’t matter. What I’d rather have is the optimization to select a SOC for me that optimizes profit for the optimization window. Quite frequently, I feel that EMHAS makes suboptimal decisions in order to reach a specific SOC when it actually doesn’t really matter.

Please help me out here, what is it with the optimization (mpc_optim) that I don’t understand?

Hi and thanks for your message.

There is no easy way to answer this. I will say it depends on how we see the optimization problem. When the optimization problem is solved the solver has no concept of what happens after the optimization window, it only sees the exact prediction_horizon you give it. Because discharging the battery almost always saves or makes money, if you do not constrain the final SOC, the mathematical absolute maximum profit will “always” be to completely empty the battery to 0% (or its safe minimum) by the very last timestep.

All of this also depends if you are thinking “day-ahead” or just MPC on a reduced time window (<24h).

On a day-ahead optimization we run once for a fixed block of time (e.g., midnight to midnight). Setting a soc_final here makes perfect sense because you want to be sure that the battery has a baseline charge ready for the start of the next day. The most typical choice here is soc_initial=soc_final.

Now for MPC it will depend on the 2 notions of receding and shrinking horizon.

If you have a receding (rolling) horizon then the optimization window always looks exactly prediction_horizon timesteps ahead. Does it make sense to set a soc_final here? It depends entirely on the length of your horizon:

  • Short Horizons (ex 1 to 6 hours): You must set a target soc_final. Otherwise, the setup might drive the solver to completely empty the battery by the end of that short hour. However, this soc_final shouldn’t be arbitrary; both soc_init and soc_final should be dynamically fed from a previously defined long-term plan (like the 24-hour schedule proposed by a day-ahead optimization). This setup will guide the short-term MPC to stay on track with a long-term daily goal.
  • Long Horizons (ex 24 hours): Setting a high soc_final here forces the optimizer to constantly chase a moving target that keeps getting pushed back every time the MPC runs. This might cause the “suboptimal” charging/discharging decisions that you are probably identifying. For long receding horizons I would say it is best to set soc_final equal to your battery_minimum_state_of_charge so the solver has maximum flexibility.

Finally the is the Shrinking Horizon case. Here the finish line is fixed to a specific time (ex midnight tonight). As the day progresses, the horizon gets shorter and shorter. Setting a target soc_final works perfectly here and it’s the situation that makes more sense to me for using MPC, because the target is rooted to a real moment in time, rather than constantly running away from the solver.

3 Likes

Would this be a big issue? Doesn’t seem to be when looking at the debug for PV forecast with Open Meteo.

[2026-03-06 08:20:00,927] INFO in forecast: Retrieving weather forecast data using method = open-meteo
[2026-03-06 08:20:00,927] INFO in forecast: Loading existing cached Open-Meteo JSON file: /share/cached-open-meteo-forecast-b.json
[2026-03-06 08:20:00,928] INFO in forecast: The cached Open-Meteo JSON file is recent (age=12m, max_age=30m)
[2026-03-06 08:20:00,940] DEBUG in forecast: get_weather_forecast returning:
                           temp_air  relative_humidity  ...    dhi    dni
2026-03-06 08:15:00+01:00       9.0                 63  ...   67.3  229.2
2026-03-06 08:30:00+01:00       9.5                 64  ...   83.2  312.1
2026-03-06 08:45:00+01:00      10.0                 63  ...   96.3  377.6
2026-03-06 09:00:00+01:00      10.6                 63  ...  107.1  433.5
2026-03-06 09:15:00+01:00      11.3                 62  ...  116.0  476.0
...                             ...                ...  ...    ...    ...
2026-03-09 07:00:00+01:00       5.8                 90  ...    0.0    0.0
2026-03-09 07:15:00+01:00       5.9                 89  ...    0.0    0.0
2026-03-09 07:30:00+01:00       6.2                 89  ...   14.5  107.6
2026-03-09 07:45:00+01:00       6.4                 88  ...   26.7  270.6
2026-03-09 08:00:00+01:00       6.8                 87  ...   36.4  390.6
[288 rows x 8 columns]
[2026-03-06 08:20:01,515] INFO in forecast: Closest module model to 405.0W found: Amerisolar_Worldwide_Energy_and_Manufacturing_USA_Co__Ltd_AS_6M_HC_405W
[2026-03-06 08:20:01,562] INFO in forecast: Closest inverter model to 6000.0W found: ABB__PVI_6000_OUTD_US_A__208V_
/app/.venv/lib/python3.12/site-packages/scipy/optimize/_chandrupatla.py:437: RuntimeWarning:
invalid value encountered in divide
[2026-03-06 08:20:01,885] INFO in forecast: Closest module model to 405.0W found: Amerisolar_Worldwide_Energy_and_Manufacturing_USA_Co__Ltd_AS_6M_HC_405W
[2026-03-06 08:20:01,926] INFO in forecast: Closest inverter model to 6000.0W found: ABB__PVI_6000_OUTD_US_A__208V_
/app/.venv/lib/python3.12/site-packages/scipy/optimize/_chandrupatla.py:437: RuntimeWarning:
invalid value encountered in divide
[2026-03-06 08:20:02,243] INFO in forecast: Closest module model to 405.0W found: Amerisolar_Worldwide_Energy_and_Manufacturing_USA_Co__Ltd_AS_6M_HC_405W
[2026-03-06 08:20:02,283] INFO in forecast: Closest inverter model to 6000.0W found: ABB__PVI_6000_OUTD_US_A__208V_
/app/.venv/lib/python3.12/site-packages/scipy/optimize/_chandrupatla.py:437: RuntimeWarning:
invalid value encountered in divide
[2026-03-06 08:20:02,317] DEBUG in forecast: get_power_from_weather returning:
2026-03-06 08:15:00+01:00     767.000000
2026-03-06 08:30:00+01:00    1669.928694
2026-03-06 08:45:00+01:00    2088.675487
2026-03-06 09:00:00+01:00    2471.072901
2026-03-06 09:15:00+01:00    2796.743311
                                ...     
2026-03-09 07:00:00+01:00       0.000000
2026-03-09 07:15:00+01:00       0.000000
2026-03-09 07:30:00+01:00     248.893481
2026-03-09 07:45:00+01:00     769.758793
2026-03-09 08:00:00+01:00    1243.312693
Freq: 15min, Length: 288, dtype: float64

This is great. It makes much more sense now and I see that I need to rethink how I set the soc_final. I have a mix of moving 24h window MPC and receding window MPC that goes down to approx 10 hours ahead at its minimum. The reason is the NordPool energy prices that only updates at 13:00 for the next day.

Again, thank you for taking your time to write down this answer to me! :pray:

1 Like

If you want to use a stable 24h rolling windows, you could have a look at GitHub - b3nn0/EpexPredictor: Predicts day-ahead electricity prices for various countries in Europe · GitHub
Especially for short horizons the MAE is really low and aligns very good with the actual prices.