Integrating SRNE MPPT Inverter with HA

Hi Mattie,

I have exact same inverter but i am unable to get data. I am not sure if it is my setting are okay cos i am getting input/output errors. Can you help

MY SERIAL SETTING

CONNECTION LOG

That is not a waveshare gateway is it? As long as you follow the settings I’ve used it should work. Check out this thread Modbus TCP Gateway Recommendation

Also there are plenty of programs to poll different addresses and try it out, I think one of them is called modpoll.

It is not a waveshare gateway. I use Elfin ew11 as my gateway. I have been using it for my old epever charge controller and it works fine.

I have also connected to this SRNE inverter via USB and I can pull data but it frequently gives an erro5 input/output error which requires me to restart HA several times a day. This is why I want to switch to ethernet.

When i had this issue on my previous inverter I switch rx and tx wires and it was okay but that is not working now. I am not sure what else to check.

I have solved the problem. In modbus config, I previously had type as rtuovertcp. Now I changed it to TCP.

Nicely done, my next project will be to send commands to the inverter. I need to control when it charges the batterybank. The plan is to control setting 6 which is charging mode if I remember correct.

So I tried writing some registers and it turned out to be very easy, I made scripts that look like this:

service: modbus.write_register
data:
  address: 57871
  value: 2
  hub: modbus_tcp

I’m pretty happy with the dash so far :slight_smile: Nevermind the failed tempsensor in my batterybank

2 Likes

How is your experience with your gateway? I’m getting failed readings for every sensor pretty often. Every few seconds each sensor gives the state “unavailable” and I wonder if its my gateway that causes this, or is it the inverter?

Also when the inverter starts getting solar power it feels like the readings are getting ridiculously slow. Almost as if the inverter CPU cant manage or so. When I try to write a register at night it writes it instantly but when I try it when the sun is out and when the inverter is inverting power I can almost not get it to write at all. Im having to spam the setting and sometimes the registry is written a few minutes later or so

What scan interval are you using? I read data every minute. I also grouped addresses together so that I have less number of query to the inverter. It seems you have several or all of your requests going to the inverter same time.

I observed that the Chinese wifi module sold along with this inverter (on Aliexpress) reads every 5 minutes so I figured they don’t want to overload the inverter. One-minute interval, however, seems to work for me for at least one week before requiring a restart of HA.

Thanks for the info, I was polling every 2 seconds! I noticed warnings in the log that said lower than 5 seconds could cause instability issues which is what I experienced in ha, it could randomly restart. I changed to 5 secs yesterday and it feels much better already.

Haven’t checked out grouping att all, maybe it’s worth looking into?

1 Like

Mine looks like this

modbus:
- type: tcp
  name: SRNE
  host: 192.168.x.x
  port: 502
  close_comm_on_error: false
  timeout: 14
  retry_on_empty: true
  retries: 10
  sensors: 
    - name: "Main Battery"
      address: 256
      slave: 255
      count: 3
      scan_interval: 60
      data_type: custom
      structure: ">3H"
    - name: "Main Panel"
      address: 263
      slave: 255
      count: 3
      scan_interval: 61
      data_type: custom
      structure: ">3H"
    - name: "Main Usage"
      address: 61487
      slave: 255
      count: 2
      scan_interval: 3600
      data_type: custom
      structure: ">2H"
    - name: "Main Load"
      address: 540
      slave: 255
      count: 4
      scan_interval: 62
      data_type: custom
      structure: ">4h"
#Power consumption by load from mains of today
    - name: Inverter_Main_load_power_daily
      unit_of_measurement: kWh
      scale: 0.1
      precision: 1
      slave: 255
      address: 61501
      input_type: holding
      scan_interval: 63
#Charge state
    - name: Load and charge state
      scale: 1
      slave: 255
      address: 267
      input_type: holding
      scan_interval: 60
#Current state of the machine
    - name: Inverter State
      scale: 1
      slave: 255
      address: 528
      input_type: holding
      scan_interval: 60

sensor:
  - platform: template
    sensors:
##SRNEInverter
      main_battery_soc:
        friendly_name: "Main Battery SOC"
        unit_of_measurement: '%'
        value_template: "{{ (states('sensor.main_battery').split(',')[0])  }}"
      main_battery_voltage:
        friendly_name: "Main Battery Voltage"
        unit_of_measurement: V
        value_template: "{{ (states('sensor.main_battery').split(',')[1]|float * 0.1)|round(1)  }}"
      main_battery_current:
        friendly_name: "Main Battery Current"
        unit_of_measurement: A
        value_template: "{{ (states('sensor.main_battery').split(',')[2]|float * 0.1)|round(1)  }}"
      main_panel_voltage:
        friendly_name: "Main Panel Voltage"
        unit_of_measurement: V
        value_template: "{{ (states('sensor.main_panel').split(',')[0]|float * 0.1)|round(1)  }}"
      main_panel_current:
        friendly_name: "Main Panel Current"
        unit_of_measurement: A
        value_template: "{{ (states('sensor.main_panel').split(',')[1]|float * 0.1)|round(1)  }}"
      main_panel_power:
        friendly_name: 'Main Panel Power'
        unit_of_measurement: W
        value_template: "{{ (states('sensor.main_panel').split(',')[2])  }}"
      main_power_generated:
        friendly_name: "Main Power Generated"
        device_class: energy
        #state_class: total_increasing
        unit_of_measurement: kWh
        value_template: "{{ (states('sensor.main_usage').split(',')[0]|float * 0.1)|round(1)  }}"
      main_power_consumed:
        friendly_name: "Main Power Consumed"
        device_class: energy
        #state_class: total_increasing
        unit_of_measurement: kWh
        value_template: "{{ (states('sensor.main_usage').split(',')[1]|float * 0.1)|round(1)  }}"
      main_load_power:
        friendly_name: "Main Load Power"
        unit_of_measurement: W
        value_template: "{{ (states('sensor.main_load').split(',')[0])  }}"
      main_load_percent:
        friendly_name: "Main Load Percentage"
        unit_of_measurement: '%'
        value_template: "{{ (states('sensor.main_load').split(',')[3])  }}"
      main_inverter_state:
        friendly_name: "Main Inverter State"        
        value_template: >-
          {% if states('sensor.inverter_state') | int == 4 %}
          Mains Powered
          {% elif states('sensor.inverter_state') | int == 5 %}
          Inverter Powered
          {% elif states('sensor.inverter_state') | int == 6 %}
          Inverter to Mains
          {% elif states('sensor.inverter_state') | int == 7 %}
          Mains to Inverter
          {% endif %}
      main_load_charge_state:
        friendly_name: "Main Charge State"        
        value_template: >-
          {% if states('sensor.load_and_charge_state') | int == 0 %}
          Not Charging
          {% elif states('sensor.load_and_charge_state') | int == 1 %}
          Start Charge
          {% elif states('sensor.load_and_charge_state') | int == 2 %}
          MPPT Charging
          {% elif states('sensor.load_and_charge_state') | int == 3 %}
          Equalizing Charging
          {% elif states('sensor.load_and_charge_state') | int == 4 %}
          Boost Charging
          {% elif states('sensor.load_and_charge_state') | int == 5 %}
          Floating Charging
          {% endif %}

Great stuff! We have some dissimilarities that I will dissect later today. What does the split in your template sensors do?

When you group the read request, the values will come in comma-separated. Split is used to separate them into individual items.

Ah that is way smarter indeed, I think I will copy that :slight_smile:

What do you think of the current measurement from the PV panels? Do you trust it? I have a 4 panels wired in 2s2p, but I feel that I dont get the amps out from the array, the first series string is 2 x 7.75A and the second is 2 x 12.6A so it should be a bit above 20A totally when paralleled… but I never got more than 8A as measurement via modbus. But today I noticed that the physical display on the inverter showed a higher amp number than the modbus reported. I wonder why that is…? I have the same address as you for the PV amps (264)

Seems that you live in a sunnier place than me at least (sweden) :slight_smile:

Yes I live in a very sunny part of the world but I also think my panels are producing less than should be. My technician tells me otherwise.

My panel voltage and power reading are quite accurate. I cannot tell about the battery reading since they don’t show on the inverter itself. I do have a Chinese wifi plug made for SRNE hybrid inverter and their reading is similar to mine on HA.

Okay, We will see when the summer comes, I installed a bigger battery system and noticed that the solar gave more power than usual, maybe I didn’t have enough power consumers before so my bigger bank has room for all solar now. I can get voltage, current and calculate the power. Even the kwh in the energy dashboard is working now. :ok_hand:

Hi guys.
This is my first post here, previously I was just reading and for now I don’t have any problems with HA. Now I force with a wall.
I got this inverter 5000W Hybrid Solar Inverter High Voltage HF4850S80-H - SRNE Solar and RS485 to Ethernet Converter by waveshare.
In first post I found a mistake with wiring, pin 7 should go to A (light brown), pin 8 should go to 8 (brown).
https://dekornik.com/wp-content/uploads/2023/02/308e1d09-9ede-43ea-abf9-bb12cce60042.jpg
but after connecting I still has no data

Module Name: RS485 TO ETH
Current IP Address: 192.168.2.224
MAC Address: d4-ad-20-4b-72-42
Remote IP/TX/RX-1 : 0.0.0.0 / 0 byte / 0 byte
-2 : 0.0.0.0/ 0 byte / 0 byte
-3 : 0.0.0.0/ 0 byte / 0 byte
-4 : 0.0.0.0/ 0 byte / 0 byte
-5 : 0.0.0.0/ 0 byte / 0 byte
TX Count/RX Count: 0/ 144 bytes

Waveshare is configured exactly like in screenshots and I try this modbus yml

modbus:

  • name: modbus_tcp
    type: rtuovertcp
    host: 192.168.2.224
    port: 8888
    sensors:
    #Battery level percentage
    • name: Modbus_Inverter_BatteryLevel
      unit_of_measurement: ‘%’
      scale: 1
      slave: 1
      address: 256
      scan_interval: 60
      input_type: holding

solved


Baud Rate 9600 and everything go well

Hi Mattie
I have a question.
How did you setup energy dashboard? I mean battery storage. SRNE inverter doesn’t give data in kWh. Mathematic is simple but I don’t know how to setup it in HA:(

Hi! You were right about the colors, my bad. Actually I think I have them the other way around, I dont really think it matters? I tried a lot in the beginning when I didnt get any data so I guess I just left them as that when it finally worked.

As for the energy dashboard I got influx and grafana if you wanna go and do those handsome graphs.

And in hassio I have been testing out different calculations for my template sensors, I’m sticking with these at the moment, the battery charge/discharge actually seems pretty acurate even tho I use a non changing 24.8 for voltage, I have been thinking about making an input_number that gets populated by the current voltage every hour to make these calculations instead in the future:

      inverter_overhead_daily:
        friendly_name: Inverter Overhead
        device_class: energy
        unit_of_measurement: 'kWh'
        value_template: >
          {{ (states('sensor.daily_inverter_ac') | float(0) + states('sensor.inverter_battery_discharge_ah_daily') | float(0) - states('sensor.inverter_battery_charge_ah_daily') | float(0) - states('sensor.daily_energy_ac') | float(0) - states('sensor.daily_soluttag_energy') | float(0) - states('sensor.daily_studioserver_energy') | float(0)) | round(1) }}

      inverter_battery_charge_ah_daily:
        friendly_name: Batteri laddat idag
        device_class: energy
        unit_of_measurement: 'kWh'
        icon_template: mdi:battery-high
        value_template: >
          {{ (states('sensor.daily_inverter_battery_charge_ah') | float(0) * 27.8 / 1000 | float) | round(2) }}  
          
      inverter_battery_discharge_ah_daily:
        friendly_name: Batteri urladdat idag
        device_class: energy
        unit_of_measurement: 'kWh'
        icon_template: mdi:battery-high
        value_template: >
          {{ (states('sensor.daily_inverter_battery_discharge_ah') | float(0) * 24.8 / 1000 | float) | round(2) }}

      inverter_battery_charge_energy:
        friendly_name: Batteri laddat Increasing
        device_class: energy
        unit_of_measurement: 'kWh'
        icon_template: mdi:battery-high
        value_template: >
          {{ (states('sensor.modbus_inverter_battery_charge') | float(0) * 24.8 / 1000 | float) | round(2) }}

      inverter_battery_discharge_energy:
        friendly_name: Batteri urladdat Increasing
        device_class: energy
        unit_of_measurement: 'kWh'
        icon_template: mdi:battery-high
        value_template: >
          {{ (states('sensor.modbus_inverter_battery_discharge') | float(0) * 24.8 / 1000 | float) | round(2) }}

      inverter_battery_power:
        friendly_name: Batteribank effekt
        device_class: power
        unit_of_measurement: 'W'
        icon_template: mdi:flash
        value_template: >
          {{ (states('sensor.modbus_inverter_batteryv') | float(0) * states('sensor.modbus_inverter_batterya') | float) | round(1) }}

      inverter_battery_power_kwh:
        friendly_name: Batteribank effekt kWh
        device_class: power
        unit_of_measurement: 'kWh'
        icon_template: mdi:flash
        value_template: >
          {{ (states('sensor.inverter_battery_power') | float(0) / 1000 | float(0) ) | round(2) }}

I use the battery charge discharge in Ah from modbus

#Accumulated battery charge AH
      - name: Modbus_Inverter_battery_charge
        unique_id: Modbus_Inverter_battery_charge
        scan_interval: 245
        unit_of_measurement: ah
        state_class: total_increasing
        device_class: energy
        scale: 1
        precision: 1
        slave: 1
        address: 61492
        input_type: holding
        
#Accumulated battery discharge AH
      - name: Modbus_Inverter_battery_discharge
        unique_id: Modbus_Inverter_battery_discharge
        scan_interval: 260
        unit_of_measurement: ah
        state_class: total_increasing
        device_class: energy
        scale: 1
        precision: 1
        slave: 1
        address: 61494
        input_type: holding

My latest version of the solar-dashboard looks like this:

Do you get any unavailable states when the sun is out from your modbus waveshare gateway? My current problem is that when the sun is out I get “unavailable” state very often, this only happens when the sun is out, almost as if the inverter prioritizes the internal mppt calculation and not the modbus protocol when it has to “work more”

Wow
Thanks for you Mattie I learned what is template sensor. Game changer I have to say.
I have no problem with states. After 3 days its looks solid.
Did you connected GND wire to waveshare gateway because you didn’t mention about it. Or try my baud rate settings.
Ps. Do you have SRNE address book, I want to look inside