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

Love what you’re doing here, but I can’t get it to work :confused:

I’ve just made a toggle switch while I wait for a proper zigbee switch for my car charger. Below is my configuration. I"ve turned logging on and see an update every 10s, but not much more. What have I filled in wrong??

alias: Car Solar Charge
description: ""
use_blueprint:
  path: pv_excess_control.yaml
  input:
    pv_power: sensor.56_bambridge_st_weetangera_solar_power
    import_export_power: sensor.56_bambridge_st_weetangera_grid_power
    appliance_switch: input_boolean.car_charger_test
    defined_current: 8
    appliance_priority: 1
    automation_id: Car Solar Charge

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:44:26.956113

11:44:26 AM - 4 seconds ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:44:16.956113

11:44:16 AM - 14 seconds ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:44:06.956113

11:44:06 AM - 24 seconds ago

OctoPrint Estimated Finish Time changed to July 19, 2023 at 3:56 PM

11:43:59 AM - 32 seconds ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:43:56.956113

11:43:56 AM - 34 seconds ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:43:46.956113

11:43:46 AM - 44 seconds ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:43:36.956113

11:43:36 AM - 1 minute ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19 11:43:26.956113

11:43:26 AM - 1 minute ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19T11:43:16.956113

11:43:16 AM - 1 minute ago

file_pv_excess_control_on_time has been triggered by time 2023-07-19T11:43:06.956113

Ah! Might have the problem. You need watts but my sensor outputs kW. I’ll make some template sensors tonight and see if that fixes it

Nope, another sunny day. Grid power now showing -4250W but my dummy plug I’ve set to turn on at 8A, 230V is not turning on.

I get file_pv_excess_control_on_time has been triggered by time 2023-07-20T11:59:56.956113 in the logs every 10 seconds, I enabled debug logging in config, but not getting anything referencing solar in home-assistant.log.

Any thoughts?

Edit: Not sure what happened, but a restart seems to have fixed it!

Thanks again for some great functionality. I can’t help but think this might be better as an addon instead of a blueprint though?

Hello, i would like to test switch a Phillips Hue lamp in case of excess power, but unfortunately it doesn’t work.

The “sensor.power_meter_active_power” shows the current that is fed in. For “appliance_switch” I selected the lamp. Is that correct?

Here my configuration:

> alias: Überschussschaltung_lampe_test
> description: ""
> use_blueprint:
>   path: pv_excess_control.yaml
>   input:
>     automation_id: Überschussschaltung_lampe_test
>     pv_power: sensor.inverter_active_power
>     import_export_power: sensor.power_meter_active_power
>     appliance_switch_interval: 2
>     appliance_switch: light.turm_1
>     appliance_on_only: false
>     defined_current: 0.1
>     min_current: 0.1
>     max_current: 0.5
>     solar_production_forecast: sensor.forecast_remaining_today

In the Logbook of Home Assistant i only see the message: “file_pv_excess_control_on_time has been triggered by time 2023-07-21 07:24:05.291857”
But no more log are available. All settings for log in configuration.yaml are set!

Does anyone have a hint?

@InventoCasa is it possible to add a variable condition?
like “if temperature in sleeping room is > 25 degree”

i would like to start my air conditioner if pv excess is enough, but only if my room is too hot :slight_smile:
or do i need a workaround with another automation?

an „only off“ option would also be very helpfull

the log says it’s triggered, did you trigger your light manually or did the automation run?

alias: PVEXC
description: “”
use_blueprint:
path: pv_excess_control.yaml
input:
pv_power: sensor.solar_truepower
dynamic_current_appliance: true
appliance_current_set_entity: number.miki_charging_amps
min_current: 2
appliance_phases: 3
defined_current: 3
appliance_switch: switch.miki_charger
automation_id: automation.inventocasa_pv_excess_optimizer
import_export_power: sensor.mypoweruse

I try to test but The system cannot work.

Hello @InventoCasa ,

First of all, thank you very much for this superb blueprint as it seems to help optimizing the Solar Excessed Power very nicely. Anyway, I tried the blueprint and the log produced this error.

My PV system is without a battery and I am currently using ‘Combined Import/Export Power’ entity and leave ‘Export Power’ and ‘Load Power’ empty. My Inverter is Huawei SUN-2000 and the integration exposes ‘Total Load’ and ‘Total Export’ sensor but not real time ‘Load’ and ‘Export’ so I assumed that ‘Combined Import/Export Power (Named ‘Active Power’)’ is a better option for me since that sensor provides both positive and negative number as per instructed.

I tried to find the solution in this thread by myself but I can’t seem to find any helpful information. The ‘num=unavailable’ error seems to occur to one user but he has battery in his system so his solution doesn’t seem to work for me.

Can you or anyone suggest what to do to solve this error producing in the log?

Thank you and looking forward to hearing from you.

Just a quick question. Probably looking over it. Am I seeing this right? At ‘Automation id’, do I put the name of the automation created with the blueprint? And ‘Appliance entity’ I put whatever has to be triggerd when there is enough sun? Now I put an other automation by ‘appliance entity’. In this auotmation I have my dishwasher turned on, set to the right program and started.
I now see that the automation with the blueprint gets triggerd, but the automation to start the dishwasher doesn’t.

Apologies if this has been covered before, i have had a good read through and tried a few things but no luck.

I have set up this to test with quite a low power threshold. I can see the expected logbook entries repeating, but don’t appear to have the full debug logging working:

In configuration.yaml:

image

In logging, i see the expected entries:


file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:47:26.985743
3:47:26 PM - 1 second ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:47:16.985743
3:47:16 PM - 11 seconds ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:47:06.985743
3:47:06 PM - 21 seconds ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:46:56.985743
3:46:56 PM - 31 seconds ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:46:46.985743
3:46:46 PM - 41 seconds ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:46:36.985743
3:46:36 PM - 1 minute ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:46:26.985743
3:46:26 PM - 1 minute ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:46:16.985743
3:46:16 PM - 1 minute ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:46:06.985743
3:46:06 PM - 1 minute ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:45:56.985743
3:45:56 PM - 2 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:45:46.985743
3:45:46 PM - 2 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:45:36.985743
3:45:36 PM - 2 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:45:26.985743
3:45:26 PM - 2 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:45:16.985743
3:45:16 PM - 2 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:45:06.985743
3:45:06 PM - 2 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:44:56.985743
3:44:56 PM - 3 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:44:46.985743
3:44:46 PM - 3 minutes ago
file_pv_excess_control_on_time has been triggered by time 2023-08-08T15:44:36.985743

Automation config:

alias: Excess PV
description: ""
use_blueprint:
  path: homeassistant/pv_excess_control.yaml
  input:
    automation_id: other_switch_solar
    appliance_switch: switch.otherswitch
    pv_power: sensor.solaredge_ac_power
    import_export_power: sensor.solaredge_m1_ac_power
    defined_current: 0.1
    actual_power: sensor.otherswitch_energy_power
    grid_voltage: 240
    appliance_switch_interval: 2

Also this in the system log:

This error originated from a custom integration.

Logger: custom_components.pyscript.file.pv_excess_control.on_time
Source: custom_components/pyscript/eval.py:1911
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 11:33:23 AM (6 occurrences)
Last logged: 11:33:43 AM

num=unknown is not a valid number between 0 and 1000000: could not convert string to float: 'unknown'
Could not update Export/PV history!: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

I had this blueprint working. then I copied the automations and changed the sensors and switches for the new devices and only one automation seems to keep functioning

This error originated from a custom integration.

Logger: custom_components.pyscript.file.pv_excess_control.on_time
Source: custom_components/pyscript/eval.py:1911
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 8:54:44 PM (4 occurrences)
Last logged: 8:54:44 PM

Could not get state from entity automation.heating_garage: name 'automation.heating_garage' is not defined
Could not get state from entity automation.vanity_floor_heat: name 'automation.vanity_floor_heat' is not defined
Could not get state from entity automation.floor_heat_bathroom: name 'automation.floor_heat_bathroom' is not defined
Could not get state from entity automation.hot_water_pv: name 'automation.hot_water_pv' is not defined

What does this mean? they are set up no different to the only working one. reboots restarts disable enable doesn’t work.

Where can I find the reason why the script doesn’t run:

Executed: August 10, 2023 at 15:18:06
Result:

params:
  domain: pyscript
  service: pv_excess_control
  service_data:
    automation_id: automation.steuerung_pv_excess_optimizer_lmx
    appliance_priority: 1
    export_power: sensor.varta_battery_grid_power
    pv_power: sensor.rounded_solardedgeproduktion2
    load_power: sensor.loadpower
    home_battery_level: sensor.mb_varta_soc
    min_home_battery_level: 60
    dynamic_current_appliance: false
    appliance_phases: 1
    min_current: 6
    max_current: 16
    appliance_switch: light.h619a_435f_office
    appliance_switch_interval: 5
    appliance_current_set_entity: null
    actual_power: null
    defined_current: 6
    appliance_on_only: false
    grid_voltage: 230
    import_export_power: sensor.combined
    home_battery_capacity: 17.5
    solar_production_forecast: sensor.energy_production_today_2
    appliance_once_only: false
  target: {}
running_script: false

I’ve found solar edge import/export might be inverted to what is expected. I’m going to invert mine and test again.

What’s going wrong here? grafik

You have not followed instuctions under “Automation Entity ID”. Please read it again and use the correct name for the automation you already defined.

Facing some issue when i try to run the automation.

Error executing script. Service not found for call_service at pos 1: Unable to find service pyscript.pv_excess_control

Can you help?

i placed the py file in custom_components/pyscript folder and also restarted.

Anyone has a smart solution if data is provided by a Tibber Pulse?

power => only positive values if more energy from grid needed than from solar is provided
power production => only positive values if more energy returned than consumed

Edit: Maybe this should be enough and use it as load power?

  - platform: template
    sensors:
      load_power:
        friendly_name: Load Power
        unit_of_measurement: "W"
        value_template: '{{ states("sensor.power") |float - states("sensor.power_production") | float }}'

Here is my optimized version for me:

alias: Turn on/off PV Switch Automation
description: ""
trigger:
  - platform: state
    entity_id:
      - schedule.force_pv_switch
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: ABC
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
    enabled: true
  - if:
      - condition: state
        entity_id: schedule.force_pv_switch
        state: "on"
    then:
      - service: automation.turn_off
        data: {}
        target:
          entity_id: automation.pv_switch
      - if:
          - condition: state
            entity_id: switch.1
            state: "off"
        then:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.1
    else:
      - service: automation.turn_on
        data: {}
        target:
          entity_id: automation.pv_switch
mode: single

If schedule is on, deactivate the PV excess automation and start it directly. If schedule is off, activate PV excess automation again.

Hello at all, thanks for this blueprint.

I am currently planning my pv system and trying to figure out if I need an expensive energy mgmt system.
Most of my appliances can be done through the blueprint (car charging, buffer heating)

What is unclear to me is how to setup the dishwasher and washing machine. These are non smart devices. From what I understood my idea is as follows:

  1. Install Shelly to Dishwasher (Standard: On)
  2. Start Dishwasher as usual
  3. Logic starts
    3a. if pv excess is here keep on
    3b. If no pv excess is here turn off shelly and keep off until excess is here

Hint: This works because the dishwasher or washing machine just resume their started programs after a power loss.

So now the problem. How do I make sure the blueprint allows me to always start the machines and only when it starts with the work apply the logic.

From my understanding it needs to monitor the usual standby drain through the shelly energy meter. Once the machine starts draining more than the set standby drain the logic 3a/3b has to start.

Can this be achieved using the blueprint? If yes how do I have to configure it?

Hello community!

I’ve successfully been running Home Assistant (currently on 2023.9.2) in a Virtualbox VM for about 6 months.

Following the acquisition of an EV I’m very interested to maximise the utilisation of my connected rooftop PV system, and this Blueprint fits perfectly into that Use Case.

Following installation the Python script runs OK and the Automation is correctly dynamically changing the current of my wallbox in function of Excess PV Production.

But… after a while the script stops running in the background, so when I plug in the EV the next day when the sun is shining it doesn’t automatically starts the modulated charging.
This is without disabling the Automation.

If I restart Home Assistant, then the script starts running again, and the dynamic charging of my EV is correctly modulating again.

What could cause this? Is it common…?
What can I check to see if my installation and instance are correct??

Thanks all!