Hi,
I have two photovoltaic modules and a battery connected to my APSystems EZ1-M Inverter. To avoid feeding the powergrid I want to limit the output of the EZ1-M Inverter to meet the consumption of my home.
I installed a shelly Pro 3EM to measure my consuption and integrated my EZ1-M in Home Assistant. I designed the following automation and would like to know if that could work before I try it in my Home Assistant:
automation:
- alias: "Adjust Photovoltaic Inverter Power Output"
trigger:
- platform: numeric_state
entity_id: sensor.shellypro3em_XXXX_total_active_power
action:
- service: number.set_value
target:
entity_id: number.apsystems_wr_max_output_power
data:
value: >
{% set consumption = states('sensor.shellypro3em_XXXX_total_active_power') | float %}
{% set current_output = states('number.apsystems_wr_max_output_power') | float %}
{% set min_output = 30 %}
{% set max_output = 800 %}
{% set step = 10 %}
{% set home_consumption = consumption - current_output %}
{% if home_consumption > 0 %}
{% set desired_output = ((home_consumption // step) + 1) * step %}
{% set desired_output = current_output + desired_output %}
{% elif -9 < home_consumption <= 0 %}
{% set desired_output = current_output %}
{% else %}
{% set desired_output = current_output + ((home_consumption // step) * step) %}
{% endif %}
{% set desired_output = [desired_output | round(0, 'floor'), max_output] | min %}
{% set desired_output = [desired_output, min_output] | max %}
{{ desired_output }}
I have a Hichi IR reader and have made minimal changes to your automation, with an additional 10-second delay, as the Hichi only supplies data every 10 seconds and the inverter should also have time to react
{% set consumption = states('sensor.hichi_leistung') | float %}
{% set current_output = states('number.ez_1_max_output_power') | float %}
{% set min_output = 30 %}
{% set max_output = 800 %}
{% set step = 1 %}
{% if consumption > 0 %}
{% set desired_output = ((consumption // step) + 1) * step %}
{% set desired_output = current_output + desired_output %}
{% elif -9 < consumption <= 0 %}
{% set desired_output = current_output %}
{% else %}
{% set desired_output = current_output + consumption %}
{% endif %}
{% set desired_output = [desired_output | round(0, 'floor'), max_output] | min %}
{% set desired_output = [desired_output, min_output] | max %}
{{ desired_output }}
Maybe that’s enough:
{% set consumption = states('sensor.zahler_leistung') | float %}
{% set current_output = states('number.apsystems_ez_3_max_output_power') | float %}
{% set min_output = 30 %} {% set max_output = 800 %}
{% if -6 < consumption < 6 %}
{% set desired_output = current_output %}
{% else %}
{% set desired_output = current_output + consumption + 1 %}
{% endif %}
{% set desired_output = [desired_output | round(0, 'floor'), max_output] | min %}
{% set desired_output = [desired_output, min_output] | max %}
{{ desired_output }}
The values in the if-function are of course freely selectable, depending on how much fluctuation is allowed
Hi, after reading your post as well as some reviews on YouTube and Amazon, I’m really curious to know exactly how you’ve set things up. You mention that you have two solar panels and a battery hooked up. Specifically the battery part is really interesting to know more about. How is this connected to the EZ1-M? A simple direct connection to one of the two inputs of the inverter? Many comments I’ve read state that it’s inadvisable to connect a battery because ‘you’d fry the inverter with way too much current’. I’d expect the inverter to maintain a constant current (below the maximum) and output power. I’m hoping to use a 48 V - 50 Ah battery in combination with an EZ1-M. I’m not interested in solar panels because I already have a large installation based on micro inverters. And if you indeed are hooking up a battery directly, are you getting the rated output of 800 W max?
I injected your code yesterday in my automation and it works flawless. I needed to subtract -15W instead of adding +1W to compensate desired output vs. current output drift.
I have had this already working before with helper variables, but this is straight forward code.
Together with my 6kW batterie, I can in summer almost get 18h covered on zero power.
Thanks for the great and simple code.
Hey,
some time passed by. Thanks for the code. I am going to integrate it as soon as I fully understood and adjusted it.
However I have some questions:
You spoke about a delay of 10 seconds, where is that interval coded?
{% set desired_output = current_output + consumption + 1 %}
Where does that +1 come from?
{% set desired_output = [desired_output | round(0, 'floor'), max_output] | min %}
{% set desired_output = [desired_output, min_output] | max %}
What exacly happens here? I see it has to do with inverter min and max values of 30 and 800, but I don´t understand what “min” and “max” means. Does desired_output simply get rounded and checked to be between 30 and 800?
{{ desired_output }}
Is this where desired_output is set to the inverter? If not, where does inverter_output get set?
Hello
I’m also interested in making an ez1-m from Apsystem work on a DIY battery.
Do you have a photo or diagram of your facilities?
Of course, the piloting with HA would be great.
I also read that the micro inverter sometimes loses the radio signal and suddenly doesn’t react for 30 to 45 minutes.
Have you noticed this phenomenon?
I'm new in HA and this is really impressive and thanks for sharing.
I've been analyzing the code in order to reduce the number of times a value is flashed on inverter memory. Base on your code I've added conditions and a different logic:
automation:
- alias: "PV Zero Feed - Adjust Photovoltaic Inverter Power Output to House Consumption"
trigger:
# house kWh consumption sensor
- platform: numeric_state
entity_id: sensor.shellypro3em_XXXX_total_active_power
conditions:
- alias: "when light"
condition: sun
after: sunrise
before: sunset
action:
# adjustment of PV inverter power output kWh to no exceed consumption kWh and obtain a 0 feed to net
- service: number.set_value
target:
entity_id: number.apsystems_wr_max_output_power
data:
value: >
#current situation of consumption and PV inverter max output - different than PV generation
{% set net_to_home = states('sensor.shellypro3em_XXXX_total_active_power') | float %}
{% set inverter_max_output = states('number.apsystems_wr_max_output_power') | float %}
#operational limits of PV inverter
{% set min_output = 30 %}
{% set max_output = 800 %}
#sensitivity
{% set step = 1 %}
{% set PV_delta_decrease= -9 %}
# difference between consumption and PV max generation allowed
{% set home_consumption = net_to_home - inverter_max_output %}
#cases
# more energy than PV max generation, then increase PV max generation if less than maximum operational
{% if home_consumption > 0 %}
{% if inverter_max_output < max_output %}
{% set desired_output = ((home_consumption // step) + 1) * step %}
{% set desired_output = inverter_max_output + desired_output %}
# decision of PV inverter output between operational range
{% set desired_output = [desired_output | round(0, 'floor'), max_output] | min %}
{% set desired_output = [desired_output, min_output] | max %}
{% endif %}
# Much less energy than PV max generation, then decrease PV max generation
{% elif home_consumption <= PV_delta_decrease %}
{% set desired_output = inverter_max_output + ((home_consumption // step) * step) %}
# decision of PV inverter output between operational range
{% set desired_output = [desired_output | round(0, 'floor'), max_output] | min %}
{% set desired_output = [desired_output, min_output] | max %}
{% else %}
# Zero Feed , do nothing
{% set desired_output = inverter_max_output %}
{% endif %}
# output value
{{ desired_output }}
do you think it will work nice?
PD. I would like to add a condition to not perform the automatation when produced PV energy is =800 or when it is zero feed case, but I don't find the solution