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

Hi, at first, many thanks to @InventoCasa for this nice project.
I played around with your script the last couple of days to implement an automation for my dishwasher and washing machine.
Thx to this, I found some bugs in my data implementation of pv informations (i have 2 inverters installed). Im generally new in this topic and not a pro in HA (but using it since 3-4 years).
For your information, I have 2 inverters (one hybrid) but at the moment no active battery in my setup.

After realising, which data I need for this automation I had to install a new “Helper” to combine the “current active power” of my two inverters.
I also installed via HACS the “Power Flow Card Plus” (GitHub - flixlix/power-flow-card-plus: A power distribution card inspired by the official Energy Distribution card for Home Assistant) to have a better view on my “current” Watts. And I think, I found a Problem with my inverter Data and your automation.
So I have no Information for “Export Power” (current Watts sending to the grit) and “Load Power” (current total Watts consumed by my household) and also I missing some “Import Power” (current Wats imported from the grit; just for completeness).
But I have a combined one of “Export Power” and “Import Power”, in your Automation called “Combined Import/Export Power”. You noticed the following:

“Sensor which contains both, your current import power from the grid (positive values) and your current export power to the grid in watts (negative values).”.

So I think here is my Problem.
My “Combined Import/Export Power”-Entity is inverted to your description. My “current import power from the grid in watts” is the negative one and if the value is positive, it shows “export power to the grid in watts”.
Can you offer a slide button to invert the values?
The “Power Flow Card Plus” I mentioned above is offering such an option for the combined value and then I can see correct Informations in my custom “Power Flow Card”.

Or am I missing such an Option or can find a “Helper” to get an inverted entity for your automation?

Many thanks to you :slight_smile:

Make a template helper of something like :

{{states('sensor.what_ever_your_combined_entity_is')|int(0) * -1}}

That will invert it. You can now do this in the UI with a preview if you are on 2023.9.x

Hey @chris345433

how did you implement your dishwasher/washing machine?

Before I invest some time getting this blueprint running (seems to be really good), I’d like to better understand the behavior. Could someone with experience what’s happening in these two situations:

  1. It’s late afternoon, the pv excess for the appliance is sufficient but will not be anymore in 30min (and the appliance will run for 2hrs). Does the script start the appliance or is it smart enough to realize that the pv excess will not be sufficient soon and not start it
  2. In the winter, based on the typical load there will not be sufficient pv excess for the appliances. Is there a way to still maximize pv consumption?

Hi folks! Been using this for a month now and I’m wondering about how it’s supposed to work, as it does not behave quite as i expected. I have 3 devices:
Water heater, 2kw, with power monitor, highest priority
Bathroom floor heating, 700w, no power monitor
Heat pump, consumtion turns on and off and varies 0-2kw for varying times, I’ve set the script to 8A as a guess, but also tried 5A and did not notice any significant difference. This has no monitoring and is the lowest priority.

In the morning they are turned on according to priority as expected, and back off again in reverse order.which is fine on good days. But the script will never turn off the two lower priority devices to make room for the higher priority as i expected, so on cloudy/overcast days it can run both low priority devices the whole day with the highest priority device never getting power despite production being more than high enough. This will make the script completely useless when winter comes, as the water heater is the only one I actually need to run on solar.

Is this how the script is supposed to work, or is it an issue with lacking power monitoring on the lower priority devices?

Thanks!

P.S.
I’ve noticed the original developer does not seem to be around the github, anyone know what’s up with that?

I would like to suggest adding a bitcoin miner as power sink in case is not worth selling the PV excess production. Secondhand old miners are cheap. I am unsure if these machines can be remotely controlled to adjust its power consumption.

1 Like

I’ve seen that suggested before, not seen an actual setup yet. Also not sure it’s a viable idea, in my case I’d need to burn the better part of 15kw 3-phase to make it useful and regulate cunsumtion from less than 1kw to 15kw in real time as clouds drift in front of the sun. I did offer a guy to rent space for a test setup here, but he did not respond to that despite how much he seemed to think one could make on it.

Hello all

I am having a similar problem to @eight10man in this post. .

I have an automation based on the stat of charge of my car: if below 50% it disables the excess solar automation to make sure my car is charge to at least 50%, and then any extra comes from excess solar.

However when the automation is disabled and re-enabled, the script stops running - similar to what @redbak describes here

Only way I have found to solve this is a restart of HA.

Any ideas what might be causing this?

My automation does nothing, what am i missing?

Executed: 21 October 2023 at 12:29:26
Result:

params:
  domain: pyscript
  service: pv_excess_control
  service_data:
    automation_id: '1697887624599'
    appliance_priority: 1
    export_power: sensor.power_meter_exported
    pv_power: sensor.input_power_with_efficiency_loss
    load_power: sensor.template_total_acumulated_power
    home_battery_level: sensor.battery_state_of_capacity
    min_home_battery_level: 100
    dynamic_current_appliance: false
    appliance_phases: 1
    min_current: 6
    max_current: 16
    appliance_switch: switch.shelly4pm_1_andar_switch_3
    appliance_switch_interval: 5
    appliance_current_set_entity: null
    actual_power: sensor.shelly4pm_1_andar_switch_3_power
    defined_current: 6
    appliance_on_only: false
    grid_voltage: 230
    import_export_power: sensor.power_meter_active_power
    home_battery_capacity: 5
    solar_production_forecast: sensor.energy_production_today_remaining
    appliance_once_only: false
  target: {}
running_script: false
limit: 10

Hello!

I’m new here and have no idea what Home Assistant and python concerns, so I ask for your indulgence if I do not notice something obvious. I tried to install PV / Solar Excess Optimizer exactly as instructed, but fail at the following point:

pv_excess_control.yaml throws me 9 same errors in Studio Code Server:

String does not match the pattern of "DEPRECATED^".

in lines 48, 59, 73, 88, 102, 147, 201, 202, 260

some googling revealed that parts of the code are considered deprecated. i tried to simply delete the lines, but as expected, no success.

Could someone direct me on how to proceed to make this work? If any other data is needed, I will endeavor to provide it.

Thanks in advance for the help!

I`m looking for some help to setup Dynamic current control to user 95% from PV production with a inverter heat pump.

For heat pump is possible to :
-switch on /off ,
-to reduce with 50% power of the device /Eco mode ,
-to change flow temperature 25-60C
-to chose another temperature curve
-to change from heating to hot water
-to read temperature from boiler
-to change hot water temperature 25-60C from boiler
-to read flow and return temperature

or over mod bus to change frequency of compressor

I’m in the same boat - the automation seems to be doing nothing, after what appears to be a proper configuration and clicking “Run” to send the data to the script.

How does one debug this script?

You should see a lot like this every 10 seconds, in your logbook.
2023-11-13 20_35_51-Window

Why are you trying to change the code? This works perfectly as per the instructions. I struggled with studio code server and ended up using file editor.

When you install the InventoCasa Blueprint it will create 2 folders.

  1. The first folder is /config/blueprints/automation/InventoCasa/ in this folder you should have a file called “pv_excess_control.yaml”
  2. The second folder is /config/pyscript in this folder you will have a file called “pv_excess_control.py”

Hello everybody, just wanted to mention that I will implement some improvements and new features end of december / beginning of january.

On top of that, some of you may remember that there was a strange bug which led to the PV excess control script not being active anymore in certain circumstances / after a certain time. Today I found out what the problem is, and how you can solve it with a workaround until I can fix it:

→ 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 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
1 Like

Hello, newbie here, I have trouble with the manual installation, clone/download etc.
I cannot find a detailed “how to” or a video showing the detailed installation process.
I’m also worrying of the automatic update in case of a manual installation.
Do someone have some links to help me ?
Thanks !

First of all thanks for writing and sharing this great automation, I can see a lot of thought has gone into this around its flexibility and varied use cases.

I initially had a lot of dramas getting this working as I’m export limited to just 1500w (15KW 3-phase system) by my power provider and it just never have enough export capacity for this automation to control, so have modified to estimate available PV generation using forecast.solar integration. (Ive submitted a PR)

Here’s a before and after screenshot (with some debugging occurring in the middle) of charging my Tesla at near full 11KW capacity after a ~500Km round trip the night before, It charged from ~30% → 75% all on solar!

I also had dishwasher, dryer and washing machines on at home at the time, so the load was fairly dynamic.

Note: I had better accuracy using the next hours forecast over the current hour one. These estimates are a combination of two arrays entities, East and West, both 7.5 KW capacity

1 Like

@madeinoz67 thanks for the PR, this will be a great addition for anyone with limited export power. I’ll have a look at your PR this week to see if I can merge it right away.

1 Like

Nice work.
One question… There is option to send “rest_command” somewhere?

( I like to use it for my MYPV ELWA control over HTTP)

Thanks for this great automation, @InventoCasa !

It would be great if there is a configuration value, at which power level e.g. 5 watts for 15 minutes the appliance turn off again.

Thanks!
Dominik