EMHASS: An Energy Management for Home Assistant

Are you using the add-on? If this is the case there is no need for the long lived access token. Or are you trying to set the docker standalone mode ?

I’m getting so stuck when trying to find my inverter and panel modules in PVLib. The config docs link to a document from 2019… I’m feeling rather stupid right now.
I’ve got JA Solar JAM66S30 modules that are 500W each.
The inverter is a Sungrow SH10RT with the small SBR096 (9.6kWh) battery.
Should I just grab whatever and then use SolCast or just pass the PV estimates myself to the service? I find it a bit problematic that the service relies on a list of available hardware in such a rapidly changing marked as home PV systems is today. I’d rather just code the required parameters of my installation.

How do I get out of this trouble?

EHMASS does not “relies” on this list of outdated hardware.
That’s why there are many option to provide your PV estimates:

  • You have the PVLib option with the “scrapping” method which is great because the PV modelling is very detailed using PVLib. But I agree the database is a bit outdated. If you can’t find a suitable hardware for you then just simply don’t use this option. Move on to the next option.
  • Pass your estimates as lists of values. You will need to format your list using templates. See the docs.
  • There is also the option to use Solcast and Forecas.Solar directly from inside EMHASS without passing any list of values. These services are fully implemented. The problem with these will be that if you are already using them on your HA instance (for example for the energy dasboard), then you will have problems with the limited number of API calls per day. But if this is not a problem then use these.
1 Like

Piece of art!

What EMHASS was forecasting for my afternoon optimisation:

What my devices reported as actual power consumption:

4 Likes

Very impressive!
These machine learning algorithms are magic. And it is good to note that we are not using neural netwroks or anything more complicated than that, just some classic machine learning algorithms :slight_smile:

@davidusb I have been following this thread for a while. Great stuff and thanks for bringing this work to the community!

My question to you would be if using Emhass is useful in my situation:

  • Only 1000w in solar (3 panels) connected to grid
  • Daily gas prices. Gas heating but potentially could deploy my AC’s (not all rooms) to do a bit more heating ins special cases (eg gas price so high using
  • No battery
  • Fully variable (1 hour slots) energy pricing which also can go negative (so there are sometimes hours where I get paid to consume power, happens once every few weeks)
  • Getting an EV in 2 months (hybrid with 33kwh bat pack)
  • I have almost no deferrable loads. The EV when it arrives & a hottub

Currently I have several automations that for instance shut of solar when prices are negative, my hottub heats only when prices are lowest in the day. I avoid doing dishwasher, dryer and washer when prices are high (as they are not connected) and actually have created a nice work around for that

Do you think I could benefit from Emhass?

Hi yes of course you can use it.
It may be useful for charging your EV on the best optimal conditions.
You can even use it for your manual management. I saw your ESP device, looks neat!
For example for each of your manually controlled devices (dishwasher, dryer, etc.) you could set then in EMHASS and use the optimization results to show on your ESP device screen when is a good moment to turn on those devices.
I think that EMHASS is helpful for anyone that has variable energy pricing.

1 Like

I would stress that optimization can prove extremely beneficial, particularly when resources are limited. It allows you to maximize the output for your household under given constraints.

If you’re actively monitoring and enhancing your usage patterns, you can discover valuable insights which can spur changes in your behavior.

A key understanding I’ve gained from using EMHASS is related to EV charging:

  • At first, I would plug in and begin charging as soon as I arrived home in the evening, due to a flat rate tariff.
  • Upon installing solar panels, I transitioned to charging only with surplus solar energy.
  • Through EMHASS, I’ve realized that at times it’s more advantageous to export power instead of charging (when prices are exceptionally high), and in other situations, it’s better to charge both from the grid and solar simultaneously (when costs are extremely low).

While the advantages of optimization and these insights may seem intuitive, there’s truly nothing more enlightening than observing the tangible impact firsthand. Seeing the effects of your decisions, guided by a tool like EMHASS, enables a deeper understanding of your energy usage. This not only reinforces the value of informed decision-making but also provides a strong motivation to continue pursuing efficient energy practices.

3 Likes

Hi Guys,

Great work david…and also thanks mark for sharing your knowledge/experience.

My first question woould be… do I need a subscription to solcast to run mpi_optimization?
I saw some of the codes that the data injected into EMHASS would be from current time to 24 hours ahead. And I saw mark is running it every minute. With limit number of API calls a day (every 4 hours max) you would be feeding solcast data at some point old data due to 4 hourly solcast sensor update.

I’m still learning the ropes on EMHASS but I think I get the daily optimization done already

No Amber data yet

1 Like

Hi folks,

I am interested to take this step, there’s so much value in this add-on, I’m surprised it’s free :slight_smile: huge thanks!

I would like to start small since I have PV, battery, solar collectors, heat pump and EV. I am in NL with Tibber hourly pricing and currently using their ML capabilities to optimize deferrable loads.

Simply put, can I use EMHASS without deferrable loads and secondly simply use all the forecasted and actuals I already have in HA to push to EMHASS API? Based on the readings, I understand this should be possible but it isn’t exactly clear to me which configs are mandatory and not.

Long write up for a short question but wanted to give you all context. Thanks in advance!

1 Like

Short answer is no you don’t need a subscription and even if you did I don’t think it would add much value to an EMHASS solution.

I find Solcast great in terms of a reasonable forecast and sets my optimisations up for the day. I use the home assistant Solcast integration so I can poll that as many times as I want without effecting the upstream API count as the results are cached locally. I also don’t find the forecasts charge much during the day certainly not minute to minute.

To run my high frequency MPC optimisation, I inject my current solar PV actual value from my inverters MODBUS sensor which is updated every 10 seconds, then I inject the other 47 forecasts from Solcast sensor to make up the full 24 hour picture.

So the current decision on which devices to run is made in live data, solar, household load, buy cost and sell price. The plan for the next periods (30 minutes - 24 hours) is based on forecasts on the same parameters. It seems to work pretty well for me. I can see if I turn on the oven or a large cloud goes overtop the other loads are tuned down.

       "pv_power_forecast": {{
          ([states('sensor.APF_Generation_Entity')|int(0)] +
          state_attr('sensor.solcast_forecast_today', 'detailedForecast')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',2000)|map('int')|list +
          state_attr('sensor.solcast_forecast_tomorrow', 'detailedForecast')|selectattr('period_start','gt',utcnow()) | map(attribute='pv_estimate')|map('multiply',2000)|map('int')|list
          )| tojson
        }},

Your setup seems ideal to use with EMHASS and the fact you have everything already in home assistant makes it even easier.

Your strategy of one step at a time is great, start with a simple model and inject your household load and solar forecast, then include your dynamic pricing.

Get each step working and don’t be afraid to roll back to a working configuration.

You can setup EMHASS in a purely passive mode so you can see what it would suggest to compare the performance with tibber. This is recommended before you start physically controlling devices through Home Assistant anyway. EMHASS builds the optimised plan and you then need to create Home Assistant automations to switch your devices according to that plan.

1 Like

Thanks for your quick answer, much appreciated! Do you have any tips for what the minimum config is for this? I’m gathering I don’t need to configure any of the PV related config variables, but only about the battery and which optimization algos to use?

I just came across this cool battery simulator integration: Battery Simulator integration/custom component for home assistant

This would allow you to run the optimizer with a virtual battery to simulate how much it would save you :slight_smile:

That battery simulation looks nice. But if you have EMHASS already up and running then just use the “perfect” optimization task and activate/deactivate the battery. Change the number of days to retrieve to whatever you want and you will have quick results comparing those scenarios. Try for example 30 days to compare for the last month with and without a battery.

But I don’t understand how that would simulate a battery?

On EMHASS the battery model is directly in the LP formulation. It is actually the exact same model from the integration that you sent. It is a simple constant efficiency battery model based on just power and energy capacity in kWh to compute the state of charge (SOC)

If you like this work please consider buying a coffee :wink:

![Buy Me A Coffee](upload://i335BTjV6hwmfpDyoyLhz4yKkLY.png)

1 Like

Thanks Mark… I just saw the utcnow…
What’s the reason behind multplying by 2000? instead of 1000? just for my sanity :smiley:
It makes sense… Thanks again

I have a 15 kW inverter, Solcast 30 minute peak interval forecast is 7.5 kWh, EMHASS requires power so I multiply 7.5 kWh / 0.5 hr * 1000 W = 15,000 W.

1 Like