PV / Solar Excess Optimizer: Auto-control appliances (wallbox, dish washer, heatpump, ...) based on excess solar power

Hi Henrik,

entity type is light, dimmerized

templating allow to calculate the value of the dimmer must be set, according of the load dimmerized.


Feature Upgrade / Improvement for standard inverters

To everybody which has a standard inverter without battery and thus no access to the different separate sensors (e.g. load power and export power): I have great news for you!

I took some time today to implement an improvement which makes it easier for you to use this blueprint:

  • Implemented handling of a combined import/export power sensor

→ If you do not have access to sensors for load power and export power, you can now just pass PV power and combined import/export power, with import being a positive and export being a negative value.


  • If you have a hybrid inverter with battery, you still should pass the separate sensors. Otherwise your home battery will always get prioritized over appliances, regardless of the specified minimum home battery level.

  • I did also implement a little fix which improves the handling of dynamic current appliances like wallboxes greatly on days with varying cloudiness, so it’s worth to update to the newest version even if you have a hybrid inverter.

Thanks @InventoCasa

to update do we just need to replace pv_excess_control.py and pv_excess_control.yaml with the new versions from github?

I guess then manually execute the automations?

@aziwa yes, correct. The complete procedure should look like this:

  • Replace both files
  • Reload automations (to reload changed things in the blueprint) or simply restart / soft restart home assistant
  • Manually execute your PV excess automations once. Make sure to also check if some things in the blueprint changed because of the update. (Should not be the case normally)
1 Like

This looks interesting. I built something similar, but will try if this is better.
One question though…does your Blueprint work solely on current excess, or does it also work with Solar Forecast? I use Solcast prediction for some of my automations in HA and have had very good experience with it

@CommanderROR it works based on real-time measurements of your solar power production.

Since somebody else also mentioned solar forecasts, where do you see the benefit of having solar forecasts integrated into the automatic control of appliances?
Because measuring in real-time and then acting upon it will always be more accurate than relying on solar forecasts.

Solcast gives me a reasonably accurate forecast. For example, yesterday I had over 40kWh of power, while today it looks like about 10, tomorrow it should be back to 30+ and over the next few Days always between 30 and 40.
Now, this doesn’t mean much in terms of excess, but it does mean that charging the car today is unlikely. I might have 1kWh of Excess, but no more and starting a charge just to stop again after half an hour is probably not ideal. The same goes for heating or cooling. If the amount of energy expected for today is about what I regularly need in one Day, then any additional tasks are probably best moved to the next day.

I originally had my AC set up to use excess Solar energy. That meant, my Solar charged the home battery, when that was done it started exporting to the grid (so, excess was detected) and the AC started up. That meant on “weak” solar days the AC started sometime in the afternoon. Often I then had 2-3kW of excess, but the AC only uses 0.3-0.6kW, so plenty still went to the grid and the AC only ran for 2 hours or so.
Now I use Forecast as part of my Automation. The AC is set to start when the sun rises. The automation checks the solcast forecast for today. If it is above 12 (my usual daily consumption is 8-10kWh) then it starts the AC immediately. That way my home battery charges slower, but it still gets fully charged by the end of the day and the AC can run all day on it’s lowest modulation, either heating or cooling. This allows more effective use of solar energy.

I hope this explanation makes sense…I am not fully awake yet…:see_no_evil:

@CommanderROR Your explanation did make sense, no worries :smiley:

I think what you described is already more or less possible with the blueprint / pyscript I wrote:

  • You can select a minimum home battery level for each appliance. This means, you could set this for your AC unit to, let’s say, 30%. That means that if your home battery surpasses a charge level of 30% and your excess power (= PV power - load power) is higher than the power needed by your AC unit, it will turn on.

  • Regarding “moving appliances to the next day”: This is something which is not directly possible at the moment, but you can modify the priority level for each appliance individually. Meaning, you can set your car to a low priority and other appliances to a higher priority. On days with “just-enough” excess power, your car will then be considered only after some other appliances have been considered first. Also (same as the bullet point before), you could specify a home battery level of e.g. 80% or even 100% before starting to charge your car.

  • If you are worried about your car charging being switched on and off all the time, this is also something which is considered through the appliance switch interval. If you set that e.g. to 30mins, it will only be charged if the average excess power over the last 30 mins is higher than the expected power draw of your car. (Previous mentioned conditions like priority and min. home battery level need to be fulfilled too of course)

→ One possible feature request could be to implement a power offset for each appliance.
Example: AC unit with power draw 1000W, power offset specified to 500W. The AC would turn on, even if only 500W excess power is available. What do you think about that?

By the way, you can always integrate automations based on my script/blueprint into other automations through dynamically / based on other conditions switching on and off the specific pv excess automation created through the blueprint. If it is switched off, it will be deactivated till you switch it on again.

1 Like

I think your Blueprint will work pretty well for most usecases and I am by no means complaining. In fact, I might try it combined with my other automations once my heat pump for the floor heating arrives.

There is just one thing I would like to clarify concerning your first point: the minimum battery charge is something I use in my automation as well, however, I think our definition of “excess” differs. In my Setup, the battery can charge at about 5kW. Since my solar array isn’t that big, I rarely get any excess while the battery is below 90-95% since the battery will soak it all up. Once the battery is full I then get a lot of excess that I can’t really use up, unless I charge the car which is not always needed of course.

What the forecast feature gives me is the ability to “parallel” different tasks (not the car since it is best charged at maximum available power) while the battery isn’t full. While this would be possible using just the Solar Input and the current power draw, this does not take into account how much overall energy to expect on any given day.
Let’s say I have a very sunny morning. The battery will reach 40% quickly and the normal “excess” calculation will then “think” is has power to play with. However, if the sun then drops behind clouds for the rest of the day, the battery won’t be fully charged and I would be back to buying energy from the grid.

That’s why I prefer using the forecast as a “condition” in my planning. If I know I can expect to harvest more energy that I can regularly use, so in my case about 10kWh I can then prime my automations to use the expected excess energy. If the forecast is low, then I let the system do it’s thing and store whatever it can in the battery to get me through as much as the day and night as I can manage.

Additionally…I have a variable grid energy price, so I can do planned charging from the grid when the price is low and the solar forecast is below what I would usually consume. This adds another layer of complexity (but also fun) to the equation…:wink:

1 Like

No problem, discussion is always good so I can see if I need to implement some more features!

However, if the sun then drops behind clouds for the rest of the day, the battery won’t be fully charged and I would be back to buying energy from the grid.

Okay, so if I understand correctly the only concern here is the dilemma, that if you would set the minimum home battery level to 0% (for the purpose of starting your devices as early as possible in the morning), this could mean that the battery will not be charged to 100% till sunset.
→ Is that what you meant? Or are there some other examples?

To me, that’s a valid point now, and it makes sense to include solar forecasts for this use case.
If you want you can write a feature request exactly for this on my GitHub repo. I can implement this in the upcoming weeks.

Additionally…I have a variable grid energy price

Yes, that is another interesting topic to include. It could be coupled with a minimum (charge) level for appliances and solar forecasts. You could mention that in the following feature request if you want:

1 Like

Thanks, that’s a great idea. I will try and find some time later today to write the feature requests on GitHub.

1 Like

Hey man, thanks again for your great support!
But I got some further questions (or maybe ideas for improvements):

  1. Mainly I want to use your script to “suncharge” my PHEV.
    But my Wallbox is connect via 3 phases, and my PHEV only loads with 1 Phase (max 3,6kwh).
    I can’t change the amount of used phases in my Wallbox configuration (so every charging current i submit is divided by 3). Need an electrician first, to connect my wallbox with 1 phase.
    But it would be nice if there is a posibility to ensure a fully loaded battery at a specific time.
    So if its a cloudy day and i dont get enough sunpower to charge, some kind of controlment would be nice. Like lets say I load 5% Battery an hour.
    If my battery is less than 95% an hour before defined time, get power from grid.
    If its 2 hours before check if battery is less than 90% and so on.
    Or is this possible with another automation that “overrides” my Blueprint automatisation?

  2. My heaters. I want to use your script to turn on and off aquarium heaters.
    Those heaters run with 75Watts, only if a the temperature is below a specific value.
    If I now pass the actual power consumtion via sensor, its probably 0. So the heater would turn on (I think), even if there is not enough solar power for 75W (or for 20 x 75W).
    If then some heaters turn on - and there is not enough sunpower, they will turn off.
    Wouldnt it be better here to pass a fix power consumption?
    Or do I understand your blueprint wrong?

  3. The turn on/off time. Minimum is 1 min. So I suppose, if there is enough sunpower for 1min device will turn on and vice versa.
    Is it possible to turn on some devices off immediately? (by setting this value to 0 or some seconds)?

  4. Ive got a device that should run from Monday to Saturday on a specific time (regardless to sunpower), and on sunday it only should run if tehre is enough PV power.

  5. What happens if certain automatisations are set to the same priority?
    Lets say my wallbox is 1 and 5 aquarium heaters are set to prioty 2.
    In which sequence they will turn on?

Hi there,

regarding 1: One-phase vehicle on 3-phase wallbox is no problem, I did take this into account because I have the same situation. See the blueprint description for Three phase appliance:

Tick this box if you have a three-phase appliance and your appliance is configured for three-phase power use.
Otherwise untick the box.

Meaning in your case, the box should be unticked. For ensuring a minimum battery charge, that’s something which was also requested by others. See feature request on GitHub.
I might implement this in the upcoming weeks.

regarding 2:
For those situations you have the so-called Appliance typical current draw:

[…] Relevant for deciding how much excess is needed before turning the specific appliance on.

Because of this your heater will only turn on if there is more solar excess than what you specified for the typical current draw in the blueprint. The actual power is used to regulate (especially dynamic current appliances) more accurately.

regarding 3:
That’s not possible at the moment. I thought about allowing an even smaller time window, however that will result in some bigger changes code-wise, since cron is only supporting up to one minute in terms of frequency. If you want, you can write a feature request for this on GitHub so that we can track how relevant this is for other users and what exactly the use cases are for an interval smaller than 1 minute.

regarding 4:
You can actually create another simple automation for that, which deactivates the PV excess automation on weekdays and activates it on weekends.

regarding 5:
The sequence for appliances with the same priority level will be in the same order as when adding the single blueprint-based automations.

Thanks bro!

  1. OK Ill give the wallbox a chance. But its not possible to set a proper charging amount in the Keba app either.
    If I set there 3kwh charging power. My car will charge with 1 kwh. Same if I set the charging current in homeassistant (if I set 18A my car is loading with 1380W - 6 A per phase). But my wallbox will be plugged to another place here soon. Maybe Ill then swap my Keba from work with my go e charger at home. Because the go e charger should be much “HomeAssistant friendlier”.

  2. Didnt realise I can set a value there. This means, if I set the value to 0,4A (0,4A * 230V = 92W), my heater will turn on if there is 92W PV Excess power. Great!

  3. Ill do that. For me it might be a lot of energy savings, even if its 1 min only. Because I have a lot of
    electric consumpters. But I suppose im the only one with this wich :o)

Regarding 1)
Should be no problem, I have that too and it’s normal, at least in some situations. Consider e.g. the last x% of charge in an (PH)EV - The BMS in the vehicle will always charge those last few percent with a lower charging current than specified. Same goes for when the battery is too cold or too hot.
The script will consider this through the actual power sensor, so you do not have to worry about some unwanted behaviour of the PV excess optimizer.

Regarding 2) Correct! :slight_smile:

if sun is shining ill marry you bro!

Rly great work.

This looks great! I think I might have a dilemma however. I have a 3ph supply with two hybrid inverters 6.6kw ea (& batteries). One of the inverters tracks (load, import/export) two phases and the other a single phase. Where I am in Aus electricity consumption is ‘net metered’ across the 3 phases. So if Ph1 is importing 500w and Ph2 is importing 500w and Ph3 is exporting 1000w the net metered consumption is 0. Often both inverters are configured to not export any excess solar, as depending on the wholesale price exporting actually costs. I recently got a single phase wallbox and would like to scale its charging based on excess solar.

My issues are:

  1. Can I configure the blue print to work with multiple inverters? Using template sensors could work but would fall down when there are unbalanced loads between the inverters.
  2. If the inverters are configured to not export - how can I provide a ‘guess’ to the blue print. I do have a weather station that provides solar radiation which I could math up to provide a reasonable guess.
  3. I don’t want to deplete the battery of the hybrid inverter on the same phase as the wallbox. It has a setting to maintain a level of charge so that it will draw from grid instead of battery which will work nicely if the other inverter is exporting to the grid - the ‘net metered’ usage should result in 0

I feel like I’ll need to bespoke something up as it feels a bit niche

Hi there, looks like you have a very special situation - I will try to answer your questions:

  1. In this situation it may be best to create template sensors which summarizes the PV production of all your inverters / the Load Power measured by all your inverters (since you mentioned they track different phases) and the export power of all inverters.

  2. Can I ask why in the first place your inverters are configured for non-export? Do you really have to pay money in certain circumstances for exporting to the grid? I guess the only method to approximate the current solar production is to use e.g. Solcast Solar forecast, and calculate a PV Power value based on the current to-be-expected power by passing Solcast’s Forecast this hour value to the blueprint as PV Power.

All in all, it could be worth thinking a bit more about how the script can handle multiple inverters. If you want, you can write a feature request for this on GitHub and I will see what I can come up with when I have time to address this.


Feature Update

Implemented Include Solar Forecast data · Issue #9 · InventoCasa/ha-advanced-blueprints · GitHub

  • From now on, the script can take into account Solcast solar forecasts for the current day. The purpose of this is to ensure that loads can be turned on right away when there is enough solar power in the morning, regardless of the specified minimum home battery level

  • The target for the minimum home battery level is now the end of the day

  • the remaining “non-full” / empty battery capacity is constantly checked against the remaining solar forecast. In case the optimizer detects that the window for charging the remaining battery capacity gets to narrow at the end of the day, it will turn off your controlled appliances so that the battery can charge to the specified minimum battery level

  • If you want to use this, you need to pass

    • Solcast today remaining forecast
    • your home battery capacity
  • The Solcast Integration can be installed via HACS: GitHub - oziee/ha-solcast-solar: Solcast Integration for Home Assistant


Thanks. I already saw this on GitHub. I will try and find time to test within the next few days. Great work!