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

every automation in Home Assistant can easily be turned on/off via the lovelace dashboard. Just add the automation entity to your dashboard.

You can find the debug logs in the standard home assistant logfile (if you set the loglevel of the python script to debug beforehand, according to the installation instructions in the first post)

1 Like

Hi @IventoCasa,
tnx for your reply :slight_smile:

For whatevery reason I dont get any logs.
I have it configured as discribed and I remember at the beginning there were some log entries where it was complaining about something with the switch but now absolute silcence

logger:
  default: info
  logs:
    custom_components.pyscript.file.pv_excess_control: debug

pyscript:
  allow_all_imports: true

On top of the configuration.yaml.

And here the automation. The comments are just added in this post not in the original config…

- id: '1681731625534'
  alias: pv_excess_wwk
  description: ''
  use_blueprint:
    path: pv_excess_control.yaml
    input:
      automation_id: pv_excess_wwk
      pv_power: sensor.victron_pv_charger_filtered //PV Charger Power in W, just positive values.
      export_power: sensor.netz_exportleistung_aktuell //current export
      load_power: sensor.victron_total_loads //all loads excluding battery charge in W
      home_battery_level: sensor.pylontech_battery_state_of_charge //Battery state in %
      home_battery_capacity: 15
      solar_production_forecast: sensor.solcast_forecast_remaining_today 
      appliance_switch_interval: 20
      defined_current: 1.8
      actual_power: sensor.keller_wwk300_leistung //Power of the device in W
      appliance_switch: switch.keller_wwk300_schalten  // switch

I also deleted everything an reinstalled but no changes. Currently it seams to work but getting no log output is still strange

Can you try reloading PyScript and executing the automation again?
HA Developer Options → Reload YAML section → reload PyScript.

After that, please execute the relevant automation(s) again.

I did but still no log entries.
The only way to get at least one log entry is to call

Pyscript Python scripting: pv_excess_control 

what result in

 run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 695, in call raise TypeError( TypeError: pv_excess_control() missing 21 required positional arguments 

Looks like exactly the same problem as here.

For me it solved to delete absolutely everything. Means all automations, the two copied Excesscontrol files, and pyscript. And I commented the entries in config.yaml.
After deleting everything and reinstalling like described everything works fine.
Actually I creating a backup (Ive learned) and try setting up my wallbox again.

@tomcat if it works and you get no log output, then it must be something with the way you define the logging - maybe you have accidentally two sections in your home assistant config, which both define logging params?

If it doesn’t work, it likely is a combination of different unusual circumstances. Re-installing everything, including re-installing pyscript in the process, should help then.
Maybe at some point, I will be able to reproduce this so I can implement a fix. But as long as I can’t reproduce it, no chance.

One pitfall I definitely know of: When you save your automation, and after that re-name the automation itself, this will lead to the script deleting the configured instance, because the entity id does not change when renaming an automation

Thanks for your work on this. It looks like exactly what I was looking for.

I have set this up for three of my appliance. My washing machine has run three times today… is there any way to make it run once in any 24 hour period?

@finalbillybong I guess I could include a simple “only run appliance once” switch. Till I implemented this, you could help yourself with two simple automations:

  • one, which triggers when the washing machine gets turned on and disables the PV excess automation for the washing machine
  • another one, which enables the PV excess automation for the washing machine again at midnight
1 Like

Started this using today. A few things:
I swear I read above it states to set a different battery level for each entity if you want it to start sooner. The blueprint specifically states not to do this as:

<strong>[WARNING]
This sensor must be the same for all your created automations based on this blueprint!</strong>

Am i misreading a bit? It’d be ideal to have some stuff turn on at 60, next at 70 and at 80 if battery keeps charging but don’t want to break it. I currently have 3 separate automations created from a singular blueprint.

It’s a personal thing, but amps don’t work for me in the bottom section when not wallbox’ing, again everything above talks watts, solar generation is in watts, yet entity usage is requested in amps. It just doesn’t tick that box for me if that makes sense. I only ever use amps when setting the car draw, everything else is used/monitored in watts. Not sure what a valid solution would be that doesnt add all loads of different complications for everything but I just can’t see 2.5A and turn that to 575 at a glance

I did that more as one time.
For whatever reason I dont get logging of pyscript working again
Also not if I try there hello world exaple.
Im out of ideas here :frowning:
But it looks like the automation is nevertheless working. Not shure if correctly. I keep watching it.

@AaronIsFab

The behavior of min_battery_level changed when solar forecasts were introduced. This ensures that your home battery is charged to the specified level at the end of the day, which in turn means your appliances can turn on way sooner without waiting till a specific battery level is reached.

This behavior optimizes the usage of excess solar even further, that’s why I implemented it that way.

Regarding Amps, if you have dynamic current appliances, you always set the current in amps. Since the script supports also three-phase appliances, it was logical to implement it this way.
Also I think it’s not hard to convert to amps, plus you only have to do it once when setting up the automation. Ampere = Watt/Volt

1 Like

Hello, I have a Shelly 3em energy meter and everything works fine in the home assistant, the energy data agree with the indications of panels with Hoymiles inverters and Shelly 3em consumption, import and export.

However, I have excess energy produced in the afternoon and I wanted to use it better using PV Excess Optimizer, but the application does not read entities with a - (minus) value, as I see when I have more energy produced than downloaded.
Is there any way to create a new entity in the config with a positive value that would change dynamically.

@Maximus1022012
Do you have a hybrid inverter? If not, you can use the combined import/export sensor in the blueprint.

Hello
I have Hoymiles inventors

@Maximus1022012 see my question above…

Hello all,
I’m looking all day for the error, I can not find out why my consumer is not switched on.

I use the simplest setup:
PV power current
Combined Import/Export Power
As an output I would like to switch a Fritz DECT socket.

Python script is running and I can query the values in the development environment.
A manual written automation with the values works fine.
Where can I look please to get it running?
Thx in advance, hans.

@ccle610 Please post a debug log excerpt of the time frame in which you would expect that your switch turns on, after configuring the script logger to “debug” as written in the instructions.

I have been testing and managed to create a flow in Node Red to turn on and off bathroom and ensuite heat lamps sequentially if I’m hitting my solar export limit and turn them off sequentially when I am no longer hitting my Solar export limit.

Effectively running them on power I would never generate. Handy now I should be able to use this to trigger other items to turn on during these times.


Hi Henrik,
after checking everything more than three times, I studied logging today (I have never done it with HASS).
I discovered the power of magic, wonderful!
Now it works without any changes.
Anyway - I will continue playing now and want to thank you for this very interesting automation.

Greetings from happy HaJue

1 Like

hi @InventoCasa

Im noticing a strange behaviour, maybe you can help?

I have two automations using your blueprint:

  • a dehumidifier that is on/off on priority 2, using 0.3 amps, with a 10 minute switch interval
  • my tesla, priority 1, 1 minute interval, with dynamic current control

Im noticing that when the solar generation goes down, the automations first turn off the dehumidifier, where i would have thought the expected (desired) behaviour would be to first reduce the charging amps for the car, and as a ‘last resort’ turn off the humidifier.

Any ideas whats going on?