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
305 stars 79 forks source link

Fix battery charging / discharging state #140

Closed BrettLynch123 closed 10 months ago

BrettLynch123 commented 10 months ago

copied from #139

Hi I had a problem where my sr10rt didn't know if it was charging or discharging. Anyway long story short I changed this code line from https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/blob/main/modbus_sungrow.yaml#L1765C1-L1765C85

{{ states('sensor.running_state')|int(default=0)|bitwise_and(0x2) > 0 }}

to

{% if states('sensor.running_state')|int(default=0)|bitwise_and(0x2) > 0 %} on {% else %} off {% endif %}

and did this to the discharge logic on this line https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/blob/main/modbus_sungrow.yaml#L1809

{% if states('sensor.running_state')|int(default=0)|bitwise_and(0x4) > 0 %} on {% else %} off {% endif %}