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

I like this blueprint and struggle to get it work properly. May be I have done some mistake in the settings? YAML looks like this after some changes:

alias: INVENTOCASA - PV Excess Optimizer - Car Charge
description: ""
use_blueprint:
  path: InventoCasa/pv_excess_control.yaml
  input:
    automation_id: pv_excess_car_charging
    pv_power: sensor.solax_pv_power_total
    export_power: sensor.solax_grid_export
    load_power: sensor.solax_house_load
    home_battery_level: sensor.solax_battery_capacity
    min_home_battery_level: 60
    home_battery_capacity: 12
    solar_production_forecast: sensor.solcast_pv_forecast_forecast_remaining_today
    appliance_switch: switch.easee_garage
    appliance_switch_interval: 1
    dynamic_current_appliance: true
    appliance_phases: 1
    defined_current: 7
    actual_power: sensor.easee_garage_power
    appliance_current_set_entity: sensor.easee_garage_dynamic_charger_limit
    appliance_priority: 1

Looks fine to me, in what way is it not working?

See the picture I have posted above. My car charge both from the PV and from the grid. I have expected the automation will decrease the charge current as soon PV power decrease.And vice versa. The behivour is not much logical så it could be wrong settings or I need to find some other solution.

Ah, I did not realize you where the same guy I replied to above. I have the same issue with it not decreasing the charge setting, so I can’t help. I do have a feeling it’s a bug somewhere and not a config issue (at least not in the blueprint), but I have not had the time to make a bug report yet.

And I found this messege: ‘blueprints/automation/InventoCasa/pv_excess_control.yaml’ could not be parsed, it was referenced from path ‘blueprints/automation/InventoCasa/pv_excess_control.yaml’.This file will be ignored. Error(s): - YAMLSemanticError: Multi-line double-quoted string needs to be sufficiently indented - YAMLSemanticError: Multi-line double-quoted string needs to be sufficiently indented

How to reduce pyscript_running entries in the database ?

Hello, my HA database weight increase a lot (30Gb) . So I started to look for a solution to decrease its size and I found this post:

Very interesting.
But when I check the database size with SQLite Web I get a lot of entries for pyscript_running.


I use pyscript only for PV solar excess optimizer.

I guess I’m not the only one in this case. How do you guys, manage to keep your database light?
Do you have any advices ?

EDIT:
I used this:

recorder:
  exclude:
    event_types:
      - pyscript_running

i get this error message


i have the file in this directory
/homeassistant/custom_components/pyscript/pv_excess_control.py

Hi.
you have to put the script to: /homeassistant/pyscript (not nested in the custom_component folder)

Hello,
I always see the following warning in Studio Code Server when editing any file (not pv_excess_control but any file).

Do all of you also get this warning?
did I do something wrong or is it normal?

image

Thank you :slight_smile:

Thanks Henrik for this useful blueprint, Hi to the community !

In have implemented it and it is somehow working but I have 3 issues/questions
I went through this forum, but didn’t find the answers.
1/ in logbook it records logs between every sec or 10s, which is huge. (see attached file). Is it normal? And how could I reduce this frequency?
2/ Even after implementing the workaround of @stefan73, when I enable an auto, the action is not triggered even if all conditions are met and I have always to execute it manually, otherwise that action is not triggered automatically
3/ Why is the auto not immediately evaluated/executed when I enable an auto? Apparently it takes a minimum of 1 minute to perform the action even if all conditions are met
Thanks for your answers
Renaud

I have the same message and no idea what to do with it or whether something is wrong.

1 Like

Hello everyone,

first of all: I used the blueprint/script for quite a while with one device for a month without any issues. Since I added two more devices (AC’s) I have the problem that the devices randomly don’t switch off when there’s not enough excess power.

Any ideas how to debug that?

Thanks for your help!

Here’s an excerpt from my latest log-entry:

2024-09-09 21:28:42.982 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, 0, 0, 0, 2, 3]
2024-09-09 21:28:42.982 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (PV 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -402, -422]
2024-09-09 21:28:42.984 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [input_boolean.jonas_ac_auto_22deg automation.uberschuss_ac_jonas (Prio 3)] Home battery charge is sufficient (52.6/95.0 %) OR remaining solar forecast is higher than remaining capacity of home battery. Calculated average excess power based on >> solar power - load power <<: -82 W
2024-09-09 21:28:42.985 WARNING (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [input_boolean.jonas_ac_auto_22deg automation.uberschuss_ac_jonas (Prio 3)] Appliance state (=None) is neither ON nor OFF. Assuming OFF state.
2024-09-09 21:28:42.985 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [input_boolean.jonas_ac_auto_22deg automation.uberschuss_ac_jonas (Prio 3)] Average Excess power not high enough to switch on appliance.
2024-09-09 21:28:42.986 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Exception in <file.pv_excess_control.on_time> line 16:
        domain = entity_id.split('.')[0]
                 ^
AttributeError: 'NoneType' object has no attribute 'split'


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?