Collect real time inverter data from INVT iMars inverters using Elfin-EW11A

After pulling out most of my hair I’ve decided to bite the bullet and ask the Home Assistant community for help.

As the title indicates I want to collect inverter data from my INVT iMars BG12KTR-US inverter. For the time being I collect the data via the Solarman API, but it only updates about every 5 to 15 minutes, and I want realtime data.

The thought is to connect to the inverter using Modbus RTU over WiFi, but it seems as if I am missing something in the setup somewhere. I’ve tried to reach out to both INVT and my dealer to get stop bit, parity, flow control and the register map for the inverter, but have not got any response. Nevertheless, I think that after som researching on the web, I have got the Serial Port Settings right. The Elfin-EW11A is set up as a TCP-server, and I’ve tried using the Windows-app called Modbus Poll to connect to the inverter, but all I get is timeout errors. When setting up a modbus sensor in HA its only state is “Unknown”.

My modbus code looks like this:

modbus:
  - name: "elfin"
    type: rtuovertcp
    host: 192.168.1.82
    port: 8899
    close_comm_on_error: false
    delay: 2
    message_wait_milliseconds: 50
    retry_on_empty: true
    retries: 1000
    timeout: 9
    sensors:
      - name: "Solkraft sanntid"
        unique_id: "Solkraft sanntid"
        address: 12546
        slave: 1
        data_type: uint16
        input_type: input
        unit_of_measurement: W
        scale: 0.01
        scan_interval: 1
        precision: 2

I guess that the adress might be wrong, but it’s the best guess I could make after viewing a few videos on YouTube…

However, when I set the Protocol Settings on Elfin-EW11A to “None” (instead of “Modbus”) I am able to connect to the inverter and read inverter data using iMars WinExpert and iMars PhoneExpert.

This got me thinking that it might be possible to somehow find out how to communicate with the inverter by investigating how theese apps does it. I did decompile the apk found on INVT website, but unfortunately soon concluded that it is beyond my current skill level to investigate how the app communicates with the inverter. Maybe some of you would be willing to help me out? Or maybe some of you can tell me what I do wrong?

Links to the apps: https://www.invt.com/download?keywords=imars

1 Like

So… After A LOT of head-scratching I finally managed to find a way to collect at least some of the inverter data from my INVT inverter. I had to dig into the code of the Android APK, and found a file with hints of what addresses to use. The ones that I managed to find, and that I found useful is 5797 (real time power), 5633 (peak effect today) and 5655 (production today)

I have placed the a personalized version of the below code into my configuration.yaml, and the sensors has worked as I want for a few days now.

modbus:
  - name: "elfin"
    type: rtuovertcp
    host: xxx.xxx.xx.xxx ###ip address
    port: xxxx 
    close_comm_on_error: true
    message_wait_milliseconds: 500
    retry_on_empty: true
    retries: 10
    timeout: 4
    delay: 5
    sensors:
      - name: "Real time solar power"
        unique_id: "Elfin_outputpower"
        address: 5797
        slave: 1
        input_type: holding
        unit_of_measurement: W
        scan_interval: 5
        precision: 0
        scale: 1

      - name: "Production today"
        unique_id: "Elfin_kWh_today"
        address: 5655
        slave: 1
        input_type: holding
        unit_of_measurement: kWh
        scan_interval: 60
        precision: 2
        scale: 0.01

      - name: "Solar peak effect today"
        unique_id: "Elfin_peak"
        address: 5633
        slave: 1
        input_type: holding
        unit_of_measurement: W
        scan_interval: 60
        precision: 2
        scale: 1

It’s worth mentioning that in order to get reliable readings from my inverter I had to unplug the 4G logger (the one sending info to Solarman) from the RS485-port on the inverter. Failing to do so led to intermittent readings and also some wrong readings, mostly in form of unrealistic spikes. The Elfin device is connected to the EXT port oft the INVT inverter.

Please refer to the below screenshots for how to set up the Elfin-EW11A device.


Hello there!
Because of a fault on my BG12KTR-US inverter, it was replaced with an XG10KTR-Z in February (and will soon be replaced again by the 12 kW version…). I just wanted to update anyone who might be interested on how I got the new inverter into Home Assistant.

The iMars apps doesn’t work with my new inverter, so I had to find another way to obtain the correct addresses. After a few days of waiting, I finally received the INVT XG&XD Inverter Modbus RTU Protocol from my dealer. The addresses I found were in HEX format, so I had to convert them to decimal numbers.

Unfortunately, I have been unable to find the reading for the peak power so far, but the addresses that I managed to find and have found useful are 14364 (real-time power), 14483 (production today), and 14385 (cumulative total production).

My code in the configuration.yaml file now looks like the following, and has been working for a few days now:

modbus:
  - name: "elfin"
    type: rtuovertcp
    host: xxx.xxx.xxx.xxx
    port: xxxx
    message_wait_milliseconds: 30
    timeout: 5
    delay: 5
    sensors:
      - name: "Realtime power"
        unique_id: "Elfin_outputpower"
        address: 14364
        slave: 1
        input_type: holding
        unit_of_measurement: "kW"
        min_value: 0
        max_value: 14500
        scan_interval: 5
        precision: 0
        scale: 0.1

      - name: "Production today"
        unique_id: "Elfin_kWh_day"
        address: 14383
        slave: 1
        input_type: holding
        unit_of_measurement: "kWh"
        min_value: 0
        scan_interval: 300
        precision: 2
        scale: 0.1

      - name: "Cumulative production"
        unique_id: "Elfin_tot"
        address: 14385
        slave: 1
        input_type: holding
        min_value: 0
        unit_of_measurement: "kWh"
        scan_interval: 300
        precision: 2
        scale: 0.1

Hi! I wanted to say thanks a lot for this guide! Bought the Elfin-EW11A and set it up with your values on our INVT BG7KTR at it is working perfectly!
I had to remove the values close_comm_on_error, retry_on_empty and retries from the config.
Thank you very much :slight_smile:

1 Like

I also added device_class and state_class to the sensors to enable using the sensors in the energy dashboard and enable long term statistics. Here is my config:

modbus:
  - name: "elfin"
    type: rtuovertcp
    host: <your ip>
    port: <your port>
    message_wait_milliseconds: 500
    timeout: 4
    delay: 5
    sensors:
      - name: "Real time solar power"
        unique_id: "Elfin_outputpower"
        address: 5797
        slave: 1
        input_type: holding
        device_class: power
        state_class: measurement
        unit_of_measurement: W
        scan_interval: 5
        precision: 0
        scale: 1

      - name: "Production today"
        unique_id: "Elfin_kWh_today"
        address: 5655
        slave: 1
        input_type: holding
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: kWh
        scan_interval: 60
        precision: 2
        scale: 0.01

      - name: "Solar peak effect today"
        unique_id: "Elfin_peak"
        address: 5633
        slave: 1
        input_type: holding
        device_class: power
        unit_of_measurement: W
        scan_interval: 60
        precision: 2
        scale: 1
1 Like