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

Hello all.

I have also some issues to re-enable automations in the morning again - therefore I want to write down my experience here; perhaps the issue can be found with the support of the community.

Some automations are disabled at night and turned back on in the morning with an automation.
I think this is nothing special and here are a lot of example automations to do this.
Sometimes the pyscript is realising the activation (visible in the log), sometimes not.

In my case it seems, that when I restart home assistant with disabled automations, the pyscript does not recognize when they are enabled again afterwards.
When I do not restart home assistant in this period, it seems that all is working as expected.

What do you think? Do you have the same use case when the “re-enable issue” occurs?

Here is my automation in the UI :

Thanks for your fast feedback.
Well, I can not select/find your service my HA installation; maybe I’m being stupid :slight_smile:

→ I expect its the second one in my list. :innocent:

But the entity with pyscript is not existing, really.

I assume you have pyscript in your integrations?

image

This then gives this single entity that lets HA know which integration to reload.

Well, here is somehow the difference.
I have no idea what wents wrong or how to get the missing stuff.

image


OK - you will have to do it by Config Entry ID (the tickbox)

Here’s how to get the ID :

https://community.home-assistant.io/t/how-to-find-config-entry-id-to-reload-via-service-call/

Gr8 - I found the entry ID in the given file core.config_entries.
Short test of the service is executed without errors; but afterwards no debug logging anymore from pv_excess.

To be honest, I think its not the right way somehow.
Well, for me its still unclear how to setup a robust configuration.

Strange as it works 100% for me - this automation is turned off every morning at 7am for 2.5 hours, and then turned on - make sure your automation matches mine as in reload, delay 30s, re-enable automation.

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