Zero power feed with the APSystems EZ1-M

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 }}

Any opinion on that?

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,

how is the experience with the code?
Does it work well?

Thanks

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?

Cheers in advance!

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.