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

now I figured out the same issue for my installation. SQLite tells me “165283 of pyscript_running” raising every few seconds.

added now following lines to the config.yaml:

recorder:
  exclude:
    domains:
      - device_tracker
      - media_player
      - uptime
      - time_date
      - worldclock
    event_types:
      - pyscript_running

let’s see if it helps.

Hi, thanks for this great blueprint!

I am pretty new to HA in general but learning a lot every day.

I have been looking for a solution all day googling and in this thread:

How can I prevent the automation from turning off an entity that I manually turned on despite not having PV excess at the moment.

E.g. I have a heater that should use pv excess during the day but I still want to be able to use it on the evening on demand (manually switching it on via dashboard).

Anyone found a solution for that?

For anyone interested: I figured our a solution that works for the moment.

I wrote automations, that deactivate/activate the pv excess automation for that heater based on event triggers (manual activation/deactivation of the heater limited by users)

Now I only need to find another solution for the scheduler entity as the event triggered by it has “user_id: null”

alias: "Helper: Deactivate PV Excess Automation BadOG"
description: ""
trigger:
  - platform: event
    event_type: call_service
    event_data:
      service_data:
        entity_id: climate.heizung_wc
        hvac_mode: heat
    context:
      user_id:
        - xxx
condition: []
action:
  - action: automation.turn_off
    metadata: {}
    data:
      stop_actions: true
    target:
      label_id: bad
mode: single

try this - logbook entries should also be gone.

logbook:
  exclude:
    domains:
      - pyscript

recorder:
  exclude:
    domains:
      - pyscript

Hi. Thankyou for this Blueprint.

I wanted to get clarification regarding its working when the Solar System is not Exporting Excess Energy. I have yet to get a license for the export. The inverter at present generates Power depending on the load only. Is this aspect accomodated in this automation? How would it know the maximum potential at any given time? The Solcast Forcast is used for batteries only I believe. My system doesnt have batteries coupled yet.

I want to automate my Water heater and some other items. Lets say my normal load lies between 30 - 40 % of the maximum Solar Potential. How would this blueprint approximate the Excess available then ?

Again Thankyou for the effort you have put into this.

This automation is probably the most usefull I know, thanks for developing it!

My question:

is it possible to give the battery charge a low priority? lower than an appliance

Let me explain:
During the day, there are many moments when there is not enough excess power to charge my car, but it could be enough to charge the home battery.
When there is enough excess power to charge my car, the system prefer to charge the battery.

It would be more efficient to prioritize my car over the battery.
Is it possible to do so ??

A complexity is probably due to the fact my inverter automaticaly charge the battery when it detect excess power. But on the other hand, this automation has all the data, and if it start charging the car, the inverter automaticaly stop the battery charge.

Thanks a lot :slightly_smiling_face:

have you been able to solve this?
Have the same setup and I am also struggling to get this sorted.

Hi all,
First of all, this seems to be a really good stuff and thanks a lot to the developer.

I tried to create the automation but i have an issue to determine the correct sensors.
My setup is the following:
1) PV system with hybrid Huawei inverter SUN2000, and DTSU666-H as smart meter).
2) I have a Easee Charger located in the underground parking between the smart meter and the main “counter” for the house.
3) main counter for the house is located in a local in the underground parking.

Meaning the consumption of the Easee is not visible for the smartmeter.
So, when my charging station is not used, the sensor “Power meter exported” is relevant and correspond to the “exported to grid”. But if the charging station is used, the value is not accurate. It should be “Power meter exported” - “Easee charger power”=“Exported to grid”.
In the automation, I indicated: (## is just to explain here what it is, it’s not present in my automation)

</s> <s>input:</s> <s> automation_id: Start Easee Solar Excess</s> <s> grid_voltage: 240</s> <s> pv_power: sensor.inverter_active_power ##power generated by PV##</s> <s> export_power: sensor.power_meter_exported ## power "exported to grid" before charging station##</s> <s> dynamic_current_appliance: true</s> <s> appliance_switch: switch.1_charger_enabled_2</s> <s> appliance_current_set_entity: "1" </s> <s> appliance_phases: 3</s> <s> actual_power: sensor.1_power ##power consumed by the Easee Charger##</s> <s>

I don’t indicate Load power nor Combined Import/Export Power and I’m not sure this is correct.

Could someone help me to figure out how to set correctly this?
Solved by myself.

But now I have an issue to determine what has to be indicated here : Appliance SetCurrent entity

I have a 3 phases installation and the easee charger is able to have a smart charging in 1 phase and switch with 3phases at moment of the available current is high enough.
So which value i should put in Appliance SetCurrent entity?

Cannot switch on appliance, because appliance switch interval is not reached (0/1).

Anyone understand why this happens? I have reloaded the script from the ground up and it still does it, just seems to be stuck in a loop. Have the interval set to 1 minute.

'alias: delta_pro_auto_charge
description: “”
use_blueprint:
path: pv_excess_control.yaml
input:
automation_id: delta_pro_auto_charge
pv_power: sensor.givtcp_sa2142g007_pv_power
export_power: sensor.givtcp_sa2142g007_export_power
load_power: sensor.givtcp_sa2142g007_grid_to_house
home_battery_level: sensor.delta_pro_battery_level
min_home_battery_level: 60
home_battery_capacity: 3.5
solar_production_forecast: sensor.energy_production_today_remaining_3
appliance_switch: switch.delta_pro_force_charge
appliance_switch_interval: 1
dynamic_current_appliance: true
appliance_current_set_entity: input_number.pv_excess_control_amps_selector
min_current: 0.8
max_current: 14.6
defined_current: 0.8
actual_power: sensor.delta_pro_force_charge_current_power

2024-10-07 12:23:57.242 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Export history: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 3.0, 86.0, 441]
2024-10-07 12:23:57.243 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Adjusted export history: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 3.0, 86.0, 441.0]
2024-10-07 12:23:57.244 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (solar power - load power) history: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 235.0, 259.0, 270.0, 306.0, 317.0, 308.0, 316.0, 196.0, 91.0, 43.0, 38.0, 158.0, 251.0, 271.0, 288.0, 326.0, 339.0, 357.0, 442.0, 822]
2024-10-07 12:23:57.244 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Adjusted PV Excess (solar power - load power) history: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 235.0, 259.0, 270.0, 306.0, 317.0, 308.0, 316.0, 196.0, 91.0, 43.0, 38.0, 158.0, 251.0, 271.0, 288.0, 326.0, 339.0, 357.0, 442.0, 822.0]
2024-10-07 12:23:57.245 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.delta_pro_force_charge automation.delta_pro_auto_charge (Prio 1)] Home battery charge is not sufficient (9.0/60.0 %), OR remaining solar forecast is lower than remaining capacity of home battery. Calculated average excess power based on >> export power <<: 441 W
2024-10-07 12:23:57.246 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.delta_pro_force_charge automation.delta_pro_auto_charge (Prio 1)] Average Excess power is high enough to switch on appliance.
2024-10-07 12:23:57.246 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.delta_pro_force_charge automation.delta_pro_auto_charge (Prio 1)] Cannot switch on appliance, because appliance switch interval is not reached (0/1).
2024-10-07 12:23:57.247 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.delta_pro_force_charge (Prio 1)] Appliance is already switched off.

I have managed to resolve this now by removing the following options from the automation.

Home Battery Level
Home battery capacity
Remaining solar production
Min home battery level removed - Set to 100% default

Script is now working no errors
It still satisfy my needs but having the battery auto charge feature depending on remaining pv estimated generation would be handy …

Hi,
I have a question regarding priority of two different appliances:
The first appliance has the highest current draw and the highest priority.
The second appliance has lower current draw and a lower priority.

But it seems like the appliance with lower current draw was turned on before the appliance with the higher priority.

Is this the correct behaviour of the this script?

Does this work with Fronius inverters? I am totally new to HA and i just ordered my HA to begin learning and using it

When I run my automation manually the first time after creating, I get the following error message:

The automation “PV Excess Wallbox” (automation.pv_excess_wallbox) has an unknown action: pyscript.pv_excess_control.

This error prevents the automation from running correctly. This action may no longer be available or may have been caused by a typo.

To fix this error, edit the automation and remove this action.

Click Save below to confirm that you have corrected this automation.

There is no typo, but maybe I didn´t copy the two pv_excess_control files in the right directories?

Is there a way to configure this blueprint to allow some energy use from the grid? I would love for example to have my total grid power load to remain under X kwh.
(Where I live, there is a capacity tarif (Capacity Tariff in Flanders: Demystified and Solved – easyNRJ) and I would like to be able to partially charge my car from the grid, but still remain under a threshold…

1 Like

First of all… thanks for this app… if I get it up and running this would be a game changer for me!

I’ve been trying to get this working for a few days now, but it just doesn’t seem to cooperate :frowning:

I’m using a GoodWe inverter combined with a HomeWizzard P1 meter (connected to the digital electricity meter). From both, I’m able to receive various data points in my Home Assistant (HA).

For PV power, I’m using the field PV Power from my GoodWe inverter, which provides the current generation output in watts from my solar panels.

Load is represented by the field Load, also in watts, which I receive from my inverter.

For Combined Import/Export Power, I believe this corresponds to P1 Meter Power from HomeWizzard, expressed in watts. This field gives the combined value of the three phases (negative if I’m sending power to the grid, positive if I’m drawing power from it).

The only thing missing is Export Power, showing only the power I’m exporting.

To address this, I created a new entity in Home Assistant using my P1 Meter Power from HomeWizzard with the following template:

template:
  - sensor:
      - name: "Export Power"
        unique_id: "export_power"
        state: >
          {% set power = states('sensor.p1_meter_active_power') | float(0) %}
          {{ -power if power < 0 else 0 }}
        unit_of_measurement: "W"

This template sets the value to 0 when I’m drawing power from the grid (indicating power usage) and makes the value positive when I’m sending excess power to the grid. This way, I have a positive watt value for the power I’m exporting.

However, it’s not working as intended, and my device (currently, just the test lamp above my desk) is not switching on.

Here is the automation I’ve set up:

alias: Heat Pump - Excess Power
description: >-
  If there is excess power for more than 5 minutes, the boiler will be heated
  5 degrees warmer electrically.
use_blueprint:
  path: pv_excess_control.yaml
  input:
    automation_id: wp_PowerExcessV0.1
    pv_power: sensor.pv_power
    export_power: sensor.export_power
    load_power: sensor.load
    import_export_power: sensor.p1_meter_active_power
    appliance_switch: light.bureau
    appliance_switch_interval: 1
    min_home_battery_level: 0
    appliance_priority: 1000
    grid_voltage: 240

So, what am I doing wrong?


Let me know if there’s anything specific you’d like clarified further.
Thanks!!!