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

Hi everybody,

I used the power of pyscript and the easy-to-use-approach of blueprints to implement an extensive solar excess optimization, which lets you auto-control your appliances based on power excess of your PV / solar system.

Please let me know if you have questions, if you do encounter any bugs, or if you have feature requests.
For the last two topics (bugs & feature requests) you can also directly raise them on my GitHub repository: PV Excess Control



PV Excess Control

Automatically control your appliances (wallbox, heatpump, washing machine, ā€¦) based on excess solar power

Features

:white_check_mark: Works with hybrid and standard inverters

:white_check_mark: Configurable priority handling between multiple appliances

:white_check_mark: Include solar forecasts from Solcast to ensure your home battery is charged to a specific level at the end of the day

:white_check_mark: Define an On/Off switch interval / solar power averaging interval

:white_check_mark: Supports dynamic current control (e.g. for wallboxes)

:white_check_mark: Define min. and max. current for appliances supporting dynamic current control

:white_check_mark: Supports one- and three-phase appliances

:white_check_mark: Supports Only-Switch-On devices like washing machines or dishwashers

Prerequisites

  • A working installation of pyscript (can be installed via HACS)

  • (Optional: A working installation of solcast (can be installed via HACS custom repository)

  • Home Assistant v2023.1 or greater

  • Access to the following values from your hybrid PV inverter:

    • Export power
    • PV Power
    • Load Power
    • Home battery level
  • OR: Access to the following values from your standard inverter:

    • Combined import/export power
    • PV Power
  • Pyscript must be configured to allow all imports. This can be done

    • either via UI:

      • Configuration ā†’ Integrations page ā†’ ā€œ+ā€ ā†’ Pyscript Python scripting
      • After that, you can change the settings anytime by selecting Options under Pyscript in the Configuration page
    • or via configuration.yaml:

pyscript:
  allow_all_imports: true

Installation

  • Download (or clone) the GitHub repository: PV Excess Control
  • Copy both folders (blueprints and pyscript) to your HA config directory, or manually place the automation blueprint pv_excess_control.yaml and the python module pv_excess_control.py into their respective folders.
  • Configure the desired logging level in your configuration.yaml:
logger:
  logs:
    custom_components.pyscript.file.pv_excess_control: debug

Configuration & Usage

Initial Configuration

  • For each appliance which should be controlled, create a new automation based on the PV Excess Control blueprint
  • After creating the automation, manually execute it once. This will send the chosen configuration parameters and sensors to the python module and start the optimizer in the background
  • The python module stays active in background, even if HA or the complete system is restarted

Update

  • To update the configuration, simply update the chosen parameters and values in your automation, which was created based on the blueprint.
  • After that, manually execute the automation once to send the changes to the python module

Deactivation

  • To deactivate the auto-control of a single appliance, simply deactivate the related automation.

Deletion

  • To remove the auto-control of a single appliance, simply delete the related automation.

:warning: Known Bugs :warning:

Script not active after HA restart

ā†’ Solved through PR of @stefan73. Thanks!

Original Workaround description:
ā†’ The problem appears, if all your PV Excess Control automations are disabled and you restart Home Assistant.
ā†’ As a workaround, you can create this automation (make sure to fill out to entity_id):

alias: PV Excess Control Initial Trigger
description: >-
  Triggers one of the PV Excess Control Automations after starting HA to prevent
  the prevent the script from not running in the background (happens when all PV
  Excess Control Automations are switched off at startup)
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - service: automation.trigger
    data:
      skip_condition: true
    target:
      entity_id:
        - automation.[ONE_OF_YOUR_PV_EXCESS_AUTOMATIONS_HERE]
mode: single
43 Likes

Just released the first update.


Changelog

Features

  • Implemented config option for countries with different mains voltage than 230V.

Fixes

  • Fixed bug, that dynamic current appliances wonā€™t get regulated correctly
2 Likes

My solar panels and battery will be installed in a couple of weeks so Iā€™m keeping an eye on this topic. Very Interesting!

1 Like

Hello Henrik

your blueprint is exactly what I was looking for. Iā€™ll try it within the next week.
My PV system is a little special because I donā€™t export to grid due to some problems with my electricity company. When I have excessive solar power it charges the battery and afterwards the solar power is cut off. The grid export sensor will therefore always be 0.
Will the integration work anyway or do I have to wait until i finally got my export to grid problem solved?

Kind regards
Alexander

1 Like

Hello Alexander,
yes, it will work without problems if the export is always 0.

Explanation:
The Export power is only relevant if your home battery level is still lower than the minimum home battery level specified in the blueprint. In this case, the script will decide appliance control based on export power.

Consider e.g. the following three situations:
a) Your PV system produces 10kW, but your battery can only charge with 5kW and the minimum battery level is not reached. Then, those 5kW will be exported and considered as excess (and used for appliance control)
b) Your PV system produces 10kW, and your battery charges with 10kW and the minimum home battery level is not reached. The export power is 0 and no excess is available for appliance control.
c) Your PV system produces 10kW, and your battery charges with 10kW, and the minimum home battery level for appliance X (80%) is reached. Then, for appliance X, the full 10kW (minus your home load) will be considered as excess and used for appliance control.

There is also a short explanation in the blueprint for the field minimum home battery level:

Minimum power level (in percent) of your home battery, before starting to switch on your appliance.
(If home_battery_level < min_home_battery_level ā†’ Export Power will be considered for appliance switching)
(If home_battery_level >= min_home_battery_level ā†’ PV Power will be considered for appliance switching)

2 Likes

Hi Henrik,

I have a more less dumb system: Old grid-tie Inverters without any connectivity. I measure these with tasmota or ESPhome-devices.
No batteries for now (just a charger for a E-scooter).

I have:
-real time (more/less) values for the total production of all 4 inverters (solar+wind)
-real time measurement at the main fuse box with Shelly 3em (ingoing / outgoing / power-flow)
-calculated value for the consumption
-one (later more) dynamic current appliances (dumploads)

Is this all I need to get your system to work?
Any plans to integrate solar forecasts?

My goal is to have almost no grid infeed.

Yes, that should be all you need.

  • The combined total production will be the PV Power sensor
  • the calculated consumption value (assuming this is the combined power of all loads) will be the Load Power sensor
  • Since you have no home battery, you donā€™t need to provide a sensor in the ā€œhome battery levelā€ field
  • If you can measure the power exported to the electrical grid outside your house, that will be the Export Power sensor. If you do not measure that, you can provide a helper sensor here which is always 0. In future versions I will make the export power input optional so that you donā€™t have to provide a sensor here if you cannot measure your export power.

At the moment I do not plan to integrate solar forecasts since I donā€™t know what the benefit of that would be compared to ā€œreal-timeā€ control of appliances based on current excess power. The forecast would be a lot more inaccurate compared to the actual PV power.
However if you have an idea for which circumstances solar forecasts would make sense, let me know and I will think about it.

Hi Henrik,

When i tried to import the adress of the github repository, HA told me itā€™s a unsupported URL.

Is it normal ?

Eric

1 Like

Yes, you need to manually copy the files according to instructions above, since this is a combination of blueprint and pyscript.

Henrik

Well done thanks for your job !!!

But iā€™ve got a question: are you able to offer the choice of type of management of load ?

iā€™ve got a dimmer to manage my water boiler, not a dynamic current.

It this case, your blueprint will be the ā€œcouteau suisseā€ of solar excess management, and maybe the only one know at this moment !!!

Regards

@TheSmurf hereā€™s the answer to your questions:

  1. In the Prerequisites you say I need the " *Load Power" Value from my inverter. What is this?
    (I dont have got a battery)
  1. ā€œSupports dynamic current control (e.g. for wallboxes)ā€ means I can say if I have PV excess of 1000W - load my car with 1000W? If I have 3600W - load my car with 3600W and if its more start the other devices? Is it possible here to set a delay? So the walbox doesnt turn on and off all the time if its cloudy?
  1. Are you still working on this project and interested in bugs and/or feature requests?
  1. See the blueprint for an explanation. The Load Power is the combined power of all your electrical loads. If you do not have a hybrid inverter with battery, you need to get this value somewhere else at the moment.
    But you need to pay attention that you really only do pass the Load Power, which is positive at all times. You could calculate this value based on your household energy meter measurement and the current solar production.
    I will think about how I can implement something in the near future so that you may only need to pass the PV Power and the household energy meter reading, in case you do not have a hybrid inverter.

  2. Yes, exactly. A delay is not needed because of the ā€œappliance switch intervalā€, which is used as averaging interval. Consider e.g. an averaging interval of 10 minutes. If it gets cloudy, the appliance will not turn off immediately. It will turn off / regulate the current down if the average power excess within the last 10 minutes is approx. zero. Long story short, you can modify the inertia of an appliance by modifying the ā€œappliance switch intervalā€

  3. Yes, this is a very new project of mine which is actively developed. Therefore I am very interested in bug reports & feature requests.

At the moment, the script does not support dimmers, which can be set from 0-100%. However, that is something which I could implement in the near future. What entity type is a dimmer in Home Assistant? And how is the Home Assistant service called, with which the value of the dimmer can be set?

1 Like

hi @InventoCasa
This looks really great! i just installed it and will be testing tomorrow morning as soon as the sun is up!

Some feature request:

  1. is there a way to have an override: thinking of a tesla, I would need a way to have the car charge to a given state even without excess power (for instance if I want to go on a trip the next day). Maybe using a toggle switch that can either be on a lovelace dashboard or even a physical button.

  2. minimum charge / minimum value: two use cases here: a) I have a pool heat pump - I would like to be able to set a ā€˜minimum pool temperatureā€™ that will be kept regardless of solar power, and a ā€˜nice to haveā€™ pool temperature that would be reached using excess power only. b) minimum state of charge (SOC) of the Tesla regardless of solar, to be charged during off peak hours

Maybe some of the above our out oft he scope of your idea, or maybe there is a way to do this with anther automation, but just thought I would throw it in there.

Happy to help in any way I can.

Many coffees headed your way as soon!

1 Like

Hi @InventoCasa

I am getting the following error in the logs, and the automation is not working:

Could not get state from entity automation.excess_solar:_tesla: name 'automation.excess_solar:_tesla' is not defined

the logbook show this:
file_pv_excess_control_on_time has been triggered by time 2023-04-03T10:57:00

any ideas?

Hi @aziwa , it looks like you have some not allowed characters in your automation name ā€œ:ā€
Can you try to name the automation e.g. ā€œExcess Solar Teslaā€ instead? (and set the automation ID config field in the blueprint to the same name of course)

It seems the ā€œ:ā€ is causing problems.

I think the first request can be fulfilled by temporarily disabling the automation. Such a button (to enable/disable automations) can be added to a lovelace dashboard.

For the second request, I guess it could be a valid feature idea to let the user pass a specific numerical home assistant sensor, and define what level must be reached regardless of available solar power through the day. However that is something which is not that easy to generalize for all use cases. I will take that feature request with me and think about how that could be implemented without complicating the blueprint for other use cases.

sounds great! I like the idea of disabling the automation, will try that.
Would be great to have the minimum amount. let me know if I can help in any way

Thanks for the help about the ā€œ:ā€ causing issue. i re-created the automation (just renaming didnt seen to fix it). Will know if tomorrow it works!

Coffee incoming! :slight_smile:

Thanks for the coffee(s)!

After renaming (or changing some other parameters of the automation) you need to manually execute the automation once. This will send the changed config parameters to the python script.

If you donā€™t see anymore errors in the log like before, that is a good sign. Instead you should see every minute between 6:00 and 23:00 (if you configured the debug log level for the pyscript module) some debug logs about the excess power history, and if your appliance is able to turn on or not.

Great Blueprint thanks! just trying to get it working now.

One thing it needs is the ability to take into consideration is a Solar Export limit, to be able to turn the extra loads on only after a set export threshold is reached, and turn them off if your exporting less than the threshold.

In Australia single phase solar systems are often export limited to 5kW and three phase systems to 15kW and some unlucky people have a lower limit. to automate loads during this time would maximise solar generation and export as well.

@Thomas_Brady Thanks for the input!
However Iā€™m not sure I can see the benefit here of implementing the consideration of a solar export limit, since using up the excess power by yourself is more cost-efficient than exporting it to the grid - at least here in germany, where you get only ~0.08ā‚¬ per exported kWh, while you pay at least ~0.35ā‚¬ per imported kWh.

How is it for you, do you get more money per exported kWh than pay per imported kWh?

1 Like