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

Hello.

I find this blueprint today and it look like very interesting. thanks for your work!!!

My intention is use this for the pump of the swiming pool. And power on the pump when my solar production generates production to the grid.

But it will be interesting if the blueprint can add one more “input”.
I can try to explain because english is not my natural languaje :slight_smile:

I want that my pump of the swiming pool will work 6 hours per day.
I have a entity that count the hours of the pump is working (I created this sensor).

It will be interesting to include in the blueprint that, if this counter reach the maximus time defined in the blueprint. The blueprint will not power on the pump.

To you thing is a good idea? or stupid one? :stuck_out_tongue:

thanks again for your work!

You could easy add an automation that is triggered by your counter being equal to 6 hours and disables the automation used to turn the pump on.
Another automation running at midnight will re enable the automation and reset the counter to zero and the game starts over again

1 Like

thanks!!! really interesting!!!

I wonder what happens when the Car is fully charged? it will always try to charge it again and again right? Is there any easy way to implement a check if the battery is < X? If it was a normal automation it would be easy but i dont understand how to implement a If check in a blueprint :confused:

I have debug logging enabled according to the description since a few month but since a few weeks I don’t get any debug logging entries from this automation.

3 of my four automations run fine, therefore I wanted to check in the logs why my 4th automation (which I had disabled over the winter) does not run anymore. Even after HA restart.
But unfortunately no more Debug Logs…
HA Core is Level 2024.4.2.

Solved: the /config/pyscrypt directory was empty, I downloaded the current pv_excess_control.py to /config/pyscrypt and
pv_excess_control.yaml to /config/blueprints/automation/InventoCasa.
Now everything works.
Strange that how the pv_excess_control.py has vanished and that the 3 automations still worked.
Stefan

Same issue here - Downgrade helped.

@InventoCasa could you please check?

Thank you very much

Just wanted to say thank you here. @InventoCasa with your work I was successfully able to distribute my solar excess power.
I am using this blueprint now for about 1 year without any issues to automatically control my wallbox for car charging, pool pump, pool heating and some various other heating/cooling elements.

Keep up the great work! Thank you!

1 Like

I’m starting using this blueprint, but I have an issue with it.

When not in solar excess, example: after sunset. I keep getting my devices turned off (by the script)
shouldn’t the only turn off when it was previously turned on by solar excess?

With this, I was thinking if I should turn on/off the solar excess automations. But for that I need to implement an automation to identify when I’m not in/out of solar excess…
And even with this, I have another issue, if turn off the automation when the controlled device was on, it will never be turned off…

Am I missing something? Is there any other solution?

Thanks

Thank you for this amazing script, this is definitely a future standard!

Today, PV_excess_optimizer activate my car charging, when the power is 100% covered by PV production.
I want to activate my car charging when PV production represents a least 50% of the power used.

Context explanation: my solar panels do not produce enough energy to cover my needs. But still it is more interesting to use my solar production than to sell it and buy the same amount.

So my goal is not to produce 100% of the energy I use. My goal is to use 100% of the energy I produce. And I’m probably not the only person in this case.

I suppose you already met this usecase. How should I modify the params of PV_excess_optimizer ?

THanks a lot

SOLVED - It was a renamed automation entity

After changing my configuration from advanced version by stefan73 I get the following error:

2024-04-27 14:08:01.854 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Could not get state from entity automation.halo_wallbox: name 'automation.halo_wallbox' is not defined
2024-04-27 14:08:01.854 INFO (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Automation "automation.halo_wallbox" was deleted. Removing related class instance.
2024-04-27 14:08:09.667 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Exception in <file.pv_excess_control.on_time> line 246:
                first_item = next(iter(PvExcessControl.instances.values()))
                                       ^
RuntimeError: coroutine raised StopIteration
2024-04-27 14:08:11.842 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Exception in <file.pv_excess_control.on_time> line 246:
                first_item = next(iter(PvExcessControl.instances.values()))
                                       ^
RuntimeError: coroutine raised StopIteration

What can I do to fix this? I don’t find a solution by myself.

Charging the EV seems to work. What surprises me, however, is that the charging current is not regulated down if there is not enough surplus. Charging is stopped every time and restarted after a short time. Is this intentional?

In addition, the current is not only set to full A, but also sometimes to 10.5 A or 14.7 A etc.

What could be the reason for this? At least the fact that it is not regulated down is a little surprising, especially as I get a message from the vehicle every time charging is stopped.

If I try to solve this problem with the alternative script of @stefan73 I get the following logs:

2024-04-28 17:46:33.866 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Export History Buffer: []
2024-04-28 17:46:33.866 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (PV Power - Load Power) History Buffer: []
2024-04-28 17:46:43.866 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Could not update Export/PV history!: unsupported operand type(s) for -: 'float' and 'NoneType'

I have to use a combined Combined Import/Export Power entity, because I don’t really have a good entity for the load in the house.

Hi there,

Thx for the great tool. Can someone explain the priority level in the blueprint again? Do I understand it right that

999 = higher priority to switch on

Because I have the problem that the appliances that have higher priority will be always switched on after the lower ones.

Thx

Hi there,

this automation works flawlessly, just first attempt and my pool filter pump and pool heat pump respond to the PV excess power. Great work Henrik!

Just would like to ask if it is possible to somehow overload/define set_current method for my pool heat pump. It doesn’t have dynamic power control (although it slows down itself automatically when no heating is required based on water temp and provides “percentage” of max power), but does have 2 modes: normal and boost.

Would it by possible to overload set_current to something like the follows?
1 - set_current(5.5) → set_mode(normal)
2 - set_current(6.9) → set_more(boost)

I am pretty sure this is usual behavior for most heat pumps/air conditioners, to have two power modes (normal and boost/power mode):
Pool Heat pump:


Airconditioner:

Thanks for any hint regarding this.

1 Like

Overload set_current function/method: May using Service templates somehow?
See.: Service calls - Home Assistant

But how to override default entity set_current service?

Thanks once more.

1 Like

hello.
i have a stupid question.
The automation requieres to run manually one time before it start to work.

If I disable de automation, when I enable again, its neccesary to run manually one time? or its not neccesary?

my question is because I disable the automation based in the blueprint, one time per day, and enable again at 00:01

thanks a lot!

I have exactly the same question as you. And I guess many others.

We could create an entity like a numeric field that would call the corresponding modes (ie: 1.5kW for ECO, 3kW for TURBO…) and pass that entity to “Appliance SetCurrent”.
But we would need to understand what kind of entity “Appliance SetCurrent” is expecting and it’s not described in the documentation…

I also had that problem. I had configured “Appliance actual power sensor” with a sensor of the charger that reported in kW not W. I created a template helper to convert that sensor to W. I also round the new value for current down to an integer. The automation is working now.

1 Like

I would like to use the Blueprint to switch on our washing machine when there is a PV surplus, but that only makes sense if the washing machine is full and ready (we don’t have a smart washing machine). Has anyone implemented this?

As far as I have seen, there is no way to define a condition in the Blueprint / Automation. So I only see the possibility to trigger another automation via a switch from the blueprint / automation and check there whether another switch = true (washing machine loaded and ready) and then start the washing machine. Has anyone done this or is there another solution?

This one regarding the complete keba charger setup was not very straightforwad, i summarized the whole setup at my side to simplify it for the others:

configuration.yaml:

#helper for PV Excess automation - Keba does not have enable/disable switch
switch:
  - platform: template
    switches:
      keba:
        friendly_name: "Keba"
        turn_on:
          service: button.press
          target:
            entity_id: button.keba_p30_de_enable
        turn_off:
          service: button.press
          target:
            entity_id: button.keba_p30_de_disable

#helper for pV Excess automation - when input number chages Keba.set_current will be launched
input_number:
  kebacurrent:
    name: Keba Current
    initial: 5
    min: 5
    max: 16
    step: 1

I have used Keba buttons and the button.press service for the purpose of enable/disable the wall box:

Keba automation for PV Excess:

alias: Keba nabijacka podla PV 1F
description: ovladanie Keba nabijacky podla prebytkov PV 1F
use_blueprint:
  path: homeassistant/pv_excess_control.yaml
  input:
    automation_id: Keba nabijacka podla PV 1F
    pv_power: sensor.solarman_activepower_output_total
    export_power: sensor.solarman_activepower_pcc_total
    solar_production_forecast: sensor.solcast_pv_forecast_predpoved_dnes
    load_power: sensor.solarman_activepower_load_sys
    appliance_switch: switch.keba
    dynamic_current_appliance: true
    defined_current: 5
    appliance_priority: 21
    appliance_switch_interval: 15
    appliance_current_set_entity: input_number.kebacurrent
    min_current: 5
    appliance_phases: 1
    actual_power: sensor.starship_y_charger_power

switch.keba and input_number.kebacurrent is used for enabling/disabling and setting the wall box power as defined before

To change keba current, I have used the following automation triggered when input_number.kebacurrent has changed:

alias: KEBA set current
description: KEBA set current through helper
trigger:
  - platform: state
    entity_id:
      - input_number.kebacurrent
condition: []
action:
  - service: keba.set_current
    data:
      current: "{{ states('input_number.kebacurrent')|float(0) }}"
      device_id: 52aa9005d865986e0e97235e82559910
mode: single

device id: 52aa9005d865986e0e97235e82559910 is my keba P30 DE wall box, as keba.set_current requires device id as the mandatory parameter.

To fine tune the actual current for the charging, I initialize it (depending on charging mode: PV Excess or full power) when charging has started. This is the automation for the purpose:

alias: Aktualizuj current pre Keba pri zacati nabijania
description: Aktualizuj current pre Keba pri zacati nabijania podla Tesla power mode
trigger:
  - type: powered
    platform: device
    device_id: 52aa9005d865986e0e97235e82559910
    entity_id: 2fafa1feae086c272767e415d62b5e1c
    domain: binary_sensor
condition: []
action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.keba
  - if:
      - condition: state
        entity_id: input_boolean.tesla_full_power
        state: "on"
    then:
      - service: input_number.set_value
        metadata: {}
        data:
          value: 16
        target:
          entity_id: input_number.kebacurrent
    else:
      - service: input_number.set_value
        metadata: {}
        data:
          value: 5
        target:
          entity_id: input_number.kebacurrent
mode: single

device_id: 52aa9005d865986e0e97235e82559910 - is Keba_DE device and entity id: 2fafa1feae086c272767e415d62b5e1c is “charging is powered” as follows the automation trigger:

Hope it will help someone.