mkaiser / Sungrow-SHx-Inverter-Modbus-Home-Assistant

Sungrow SH Integration for Home Assistant for SH3K6, SH4K6, SH5K-20, SH5K-V13, SH3K6-30, SH4K6-30, SH5K-30, SH3.RS, SH3.6RS, SH4.0RS, SH5.0RS, SH6.0RS, SH5.0RT, SH6.0RT, SH8.0RT, SH10RT, SH5.0RT-20, SH6.0RT-20, SH8.0RT-20, SH10RT-20, SH5.0RT-V112, SH6.0RT-V112, SH8.0RT-V112, SH10RT-V112, SH5.0RT-V122, SH6.0RT-V122, SH8.0RT-V122, SH10RT-V122, SH4.6R
310 stars 80 forks source link

Battery Charging / Discharging #110

Closed Lempomat closed 1 year ago

Lempomat commented 1 year ago

Hi, first of all, thanks a lot for your modbus script. I have a problem with the "Battery charging Power" and "Battery discharging Power". I see only 0KW... The "Battery Row" value works. image

Have you got an idea?

Lempomat commented 1 year ago

Hi, so i checked the sensors and I changed this:

- name: Battery charging
        unique_id: sg_battery_charging
        availability: >-
          {{states('sensor.battery_power_raw')|is_number and 
            states('sensor.total_dc_power')|is_number and 
            states('sensor.load_power')|is_number 
          }}
        state: >-
               {% if ( ( states('sensor.total_dc_power')|int > states('sensor.load_power')|int ) ) and states('sensor.battery_power_raw')|int > 0 %}
                {# more power generated than consumed. assuming battery charging #}
                On
               {% else %} 
                Off
               {% endif %}

      - name: Battery discharging
        unique_id: sg_battery_discharging
        availability: >-
          {{states('sensor.battery_power_raw')|is_number and 
            states('sensor.total_dc_power')|is_number and 
            states('sensor.load_power')|is_number 
          }}
        state: >-
            {% if ( ( states('sensor.total_dc_power')|int < states('sensor.load_power')|int ) ) and states('sensor.battery_power_raw')|int > 0 %}
                {# more power consumed than generated and some battery power -->  assuming battery discharging #}
              On
            {% else %} 
              Off
            {% endif %}

So this worked for me.

mkaiser commented 1 year ago

Hi,

I can't comprehend, what was your issue with the two template sensors and how your removal of the case decisions regarding the forced charge / discharge fixed the issue (without this the sensors are giving a false status in forced mode)

Can you give me more information? I guess you are using an RS inverter, that does not support the running_state, because you removed it from the template sensor.

Lempomat commented 1 year ago

Hi, so the two entities had no values, because some configured entities had not the values that you defined in your "if" statements. The above configuration that I changed works correctly for me. So everything is now fine 😄

mkaiser commented 1 year ago

But now I am curious - which sensors did not work in the first place?

Lempomat commented 1 year ago

Hi,

"Battery charging Power" and "Battery discharging Power"

After I changed the if condition by this entities it worked.