Hi everybody,
I used the power of pyscript and the easy-to-use-approach of blueprints to implement an extensive solar excess optimization, which lets you auto-control your appliances based on power excess of your PV / solar system.
Please let me know if you have questions, if you do encounter any bugs, or if you have feature requests.
For the last two topics (bugs & feature requests) you can also directly raise them on my GitHub repository: PV Excess Control
PV Excess Control
Automatically control your appliances (wallbox, heatpump, washing machine, ā¦) based on excess solar power
Features
Works with hybrid and standard inverters
Configurable priority handling between multiple appliances
Include solar forecasts from Solcast to ensure your home battery is charged to a specific level at the end of the day
Define an On/Off switch interval / solar power averaging interval
Supports dynamic current control (e.g. for wallboxes)
Define min. and max. current for appliances supporting dynamic current control
Supports one- and three-phase appliances
Supports Only-Switch-On devices like washing machines or dishwashers
Prerequisites
-
A working installation of pyscript (can be installed via HACS)
-
(Optional: A working installation of solcast (can be installed via HACS custom repository)
-
Home Assistant v2023.1 or greater
-
Access to the following values from your hybrid PV inverter:
- Export power
- PV Power
- Load Power
- Home battery level
-
OR: Access to the following values from your standard inverter:
- Combined import/export power
- PV Power
-
Pyscript must be configured to allow all imports. This can be done
-
either via UI:
- Configuration ā Integrations page ā ā+ā ā Pyscript Python scripting
- After that, you can change the settings anytime by selecting Options under Pyscript in the Configuration page
-
or via
configuration.yaml
:
-
pyscript:
allow_all_imports: true
Installation
- Download (or clone) the GitHub repository: PV Excess Control
- Copy both folders (blueprints and pyscript) to your HA config directory, or manually place the automation blueprint
pv_excess_control.yaml
and the python modulepv_excess_control.py
into their respective folders. - Configure the desired logging level in your
configuration.yaml
:
logger:
logs:
custom_components.pyscript.file.pv_excess_control: debug
Configuration & Usage
Initial Configuration
- For each appliance which should be controlled, create a new automation based on the PV Excess Control blueprint
- After creating the automation, manually execute it once. This will send the chosen configuration parameters and sensors to the python module and start the optimizer in the background
- The python module stays active in background, even if HA or the complete system is restarted
Update
- To update the configuration, simply update the chosen parameters and values in your automation, which was created based on the blueprint.
- After that, manually execute the automation once to send the changes to the python module
Deactivation
- To deactivate the auto-control of a single appliance, simply deactivate the related automation.
Deletion
- To remove the auto-control of a single appliance, simply delete the related automation.
Known Bugs
Script not active after HA restart
ā Solved through PR of @stefan73. Thanks!
Original Workaround description:
ā The problem appears, if all your PV Excess Control automations are disabled and you restart Home Assistant.
ā As a workaround, you can create this automation (make sure to fill out to entity_id):
alias: PV Excess Control Initial Trigger
description: >-
Triggers one of the PV Excess Control Automations after starting HA to prevent
the prevent the script from not running in the background (happens when all PV
Excess Control Automations are switched off at startup)
trigger:
- platform: homeassistant
event: start
condition: []
action:
- service: automation.trigger
data:
skip_condition: true
target:
entity_id:
- automation.[ONE_OF_YOUR_PV_EXCESS_AUTOMATIONS_HERE]
mode: single