Let’s see if you can discover the right sensory by yourselves… list what sensors are listed in HA.
First of all a big thanks to the creator!
I am new in to the PV game and got my first success with the PV Excess Optimizer today. There are though a couple of things that I needed to change in the code.
So see it as a mix of a proposal and feedback to me whether I am doing it right.
#1 The Wallbox / Car can only do whole numbers for the current. Thus I changed:
excess_amps = round(avg_excess_power / (PvExcessControl.grid_voltage * inst.phases), 0) + prev_amps
Would it make sense to have the amps step-size adjustable?
#2 It seems the code switches an appliance on, if excess power >= the defined power. There seems no margin. I changed it to
if avg_excess_power >= defined_power+150:
This requests another 150W. Maybe the margin should be configurable. If there is no margin you can have on/off/on/off sequences.
#3 What to do with a Wallbox that does not report power
I have a Entratek (IOCharger) Wallbox. Not sure why the solar company did choose it but I guess for price. The lousy thing does not report the current power. It does report the current used but that also only with a delay of 5 minutes. The current code uses the defined power instead. For a wallbox which can be tuned to different current this seems to be a bad choice. Thus better use the current set to the charger as it is a dynamic appliance:
actual_current = _get_num_state(inst.appliance_current_set_entity, return_on_error=inst.min_current)
#4 What to do, if you only have a combined import/export meter and a battery?
I have a Fenecon Home system. The HA integration only provides combined import/export power to the grid. It features also consumption w/o charging, battery SOC and PV production power too. Now the current code does not work with that combination well. It ignores the battery. So I commented the warning and error parts from the code. And changed the power calculation to
if PvExcessControl.import_export_power:
# Calc values based on combined import/export power sensor
import_export = int(_get_num_state(PvExcessControl.import_export_power))
export_pwr = abs(min(0, import_export))
excess_pwr = int(_get_num_state(PvExcessControl.pv_power) - _get_num_state(PvExcessControl.load_power))
It is basically just the last line of the else branch copied up. This seems to work with the Fenecon system and prioritizes the car charging over the Fenecon Home battery.
Or you can put a filter on your excess power sensor to smooth the signal.
Hmm, smoothing creates an additional delay. Now the code basically already does some smoothing. It collects data every minute. If you set the Appliance On/Off switch interval to more than a minute it calculates the average in code. With an additonal filter you add the latency of the filter to that. And you also add it to switching the appliance off. So for filtering I’d rather increase the switch interval.
A trigger threshold is a common approach to avoid additional latency and also avoid on/off sequences.
Hey Henrik
Thanks to your updated post#1 with the workaround for Script notactive after restart.
Ill give it a try.
But I have a different problem.
I use your script for about 20 devices. All (usually) work fine, but one.
Here the pv automation is usually deactivated, as the device needs to be turned on on workdays.
On non workdays I use the blueprint automation.
This device very often just doesnt turn on, even if there is enoug excess power.
Here a manual executing the automation doesnt help.
But it helpes to turn on the automation and restart HA.
On next sunday (if sun is shining, ill see if your workaround works here) - but I dont think so.
Hi,
trying to setup another device I am getting the error:
2024-01-24 09:03:52.655 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Could not get state from entity automation.pv_excess_trockner_on: name 'automation.pv_excess_trockner_on' is not defined
2024-01-24 09:03:52.656 INFO (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Automation "automation.pv_excess_trockner_on" was deleted. Removing related class instance.
2024-01-24 09:03:52.657 ERROR (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Exception in <file.pv_excess_control.on_time> line 522:
del PvExcessControl.instances[a_id]
^
KeyError: 'automation.pv_excess_trockner_on'
the automation therefor looks like this:
alias: PV Excess Trockner on
description: ""
use_blueprint:
path: pv_excess_control.yaml
input:
automation_id: PV Excess Trockner on
pv_power: sensor.power_pv_current_template
export_power: sensor.active_power_outgoing
load_power: sensor.filtered_realistic_homepower
home_battery_level: sensor.scb_battery_soc
home_battery_capacity: 6
solar_production_forecast: sensor.solcast_pv_forecast_forecast_remaining_today
appliance_switch: switch.all_schalt_trockner_2
appliance_on_only: true
defined_current: 4
actual_power: sensor.all_schalt_trockner_power
as other automations work nicely … what could be cause the error?
Hi @Monster_D
here is list of attributes from Victron.
vebus part1
vebus part2
I got 2 MPPT but I guess that is not what we are looking for. It should be something from Settings or Vebus attributes.
thanks for help
Still trying to get this optimally working with my wallbox and a Model 3. Here is the observation: There are massive oscillations in the current caused by the code. The code toggles the car on at let’s say 6A/4,2kW. Assume the PV Excess Power is a few hundred watts above this. So things should be find.
With the next update cycle (for me 1 minute), the Excess Optimizer pushes the current for the car up to 9A for the next minutes. This is far too much power, so I draw power from the grid or battery. With the next minute passed, the Optimizer stops the charging process. And the game start again.
Here is the cause - took me a while: The car does not immediately change the current. E.g. when switching on, it takes approx 20 sec, before it has reached 6A. Now the code of the Optimizer takes a sample about the PV excess every 10 seconds. And the OCPP values follow even slower than the car changes current.
Then after a minute (or your configured switching time), the code does an average of the PV excess power and adapts the current. And here is the flaw: The average includes the time for all these processes to happen. So we obtain a much to high value. This explains the overshooting behaviour.
I fixed it by 1.) Not relying on the power measured but changing the code to calculate the power from the amps/phases set. 2.) Only take the average of the last 3 samples (i.e 30 sec).
→ Now it does what it should.
The python module stays active in background, even if HA or the complete system is restarted
for example, the module turns on my air conditioner if i got enough PV power, i restart HA after that action and the module still turns off my air conditioner, if the PV power is no more?
another question:
is it possible to turn on the device with a setting?
for example, if i got enough power, would like to turn on my air conditioner. no problem yet - but i want to turn it on and switch it to heating or put the Fan on Level 5
How to do that? Do i need another automation like “if air conditioner turned on via pv access control … then … put fan to level 5”?
i think this blueprint always triggers the device, right?
if i let it control my air condition for heating and it turns off the air condition at the evening, but i want to set it on via remote, the blueprint seems to turn it off again because there is not enough power from PV?
do i have to toggle it with another automation?
Not sure if this is intended behaviour or if I’ve done something wrong. I currently have my car and my hot-water using this. Car consumes 10a, while HWS consumes 16A.
HWS is priority 1
Car is priority 2
In the morning when solar export >2.2kW the car dutifully turns on, but when total export plus car is >4kW I would have expected the car to stop charging and the HWS to turn on? Is this not how the system will work? Do lower priority devices get shut down to charge higher priority, or is it only changed when solar production reduces?
wow … 20 devices … can you tell which devices you use it for?
Is there an option to maximize self used solar?
Like i have usecase that my geothermal floorheating eats 800w but i want to start to use it as soon as there is 300w PV power available even so that then it will take 500w from the grid.
I dont want to export that much to the grid
then i still get my heating for half the price and starts sooner.
This use case without batteries was so simple i made my own automation. tommorrow we will see if it works
simple explanation:
If sun above horizon
Grid energy meter when exporting 300w (meaning 300w excess solar)
activate floor heating
When importing from the grid over 600w then (for example someone turned on the oven) then
turn off floor heater
wait 5 minutes before can be triggered again for not to spam the heating coil
I’ve commented on this before, and made a suggestion in the github too i think. I had the same expectation as you, and was equally a bit surprised it did not work like that. Hopefully this will be improved in future updates.
I have a boolean sensor for each device, and have pv solar excess turn that on and off. Then i have an automation for each that turns the actual device on and chooses the appropriate settings depending on other sensors and inputs. This also allows ignoring the script if needed.
Hi @InventoCasa
Thanks one more time for this excellent project you have developed.
I am about to re-install my HA from scratch, but wondering if you have made progress on the updated version you said you were working on?
If its not too far out I will wait for you to implement the update before re-installing.
Thanks again!
Hi,
I can change the charging power of my wallbox via a service, as in the following example of automation. This works without any problems.
- id: '1707759585755'
alias: Test
description: ''
trigger:
- platform: state
entity_id:
- switch.halo_wallbox_21xxxxxxxxxm_1
attribute: cable_lock
to: 'true'
for:
hours: 0
minutes: 0
seconds: 10
condition: []
action:
- service: chargeamps.set_max_current
data:
max_current: 10
mode: single
However, I have not been able to find out how I can integrate this service call for changing the charging power in PV Excess Control.
How can I do this?
In my case I use an automation that when PV productivity stops for more than 30 mins disables the pv-excess automation where i want to use my remote