Universal Solar Inverter over Modbus RS485 / TCP custom_component (AlphaESS, Growatt, Sofar, SolaX, Solinteg, Solis, SRNE, Swatten, TIGO TSI & Qcells Q.Volt Hyb)

Edit 31st October 2022:

This custom_component has started to become a Universal Solar Inverter over Modbus RS485 / TCP Integration. Supporting Multiple brands of Inverters. Universal Solar Inverter over Modbus RS485 / TCP custom_component (AlphaESS, Growatt, Sofar, SolaX, Solinteg, Solis, SRNE, Swatten, TIGO TSI & Qcells Q.Volt Hyb) - #794 by wills106

EDIT 12th August 2021: Development of a custom_componet has begun, please see post 227 onwards Universal Solar Inverter over Modbus RS485 / TCP custom_component (AlphaESS, Growatt, Sofar, SolaX, Solinteg, Solis, SRNE, Swatten, TIGO TSI & Qcells Q.Volt Hyb) - #227 by wills106


I thought I would share how I am getting Data from my SolaX X1-Hybrid Inverter.

I do not have a Pocket WiFi dongle, but my Inverter does have a built in LAN connection.
I can connect to the Cloud through this LAN port, but I can not connect to the Local API that @squishykid Integration is using SolaX Power - Home Assistant

After performing an Intense Nmap scan I found out that port 502 is open on my Inverter.
This port is Modbus over TCP

I found what the Modbus registers are in Hex and converted them to decimal to use with HA built in Modbus Integration as the Integration Supports serial this will possibly work connected to the RS485 port if your Inverter does not have built in LAN?

As you are directly talking to the inverter you can update values as quick or slow as you want.
I am only reading values at the moment, but you can program the Inverter / Battery over Modbus.

I have setup the integration as a package so just drop the solax.yaml file into your packages folder.

There are some values that I don’t understand yet, but they are commented.

If you want an entity card with all values copy this into your card

entities:
  - entity: sensor.solax_inverter_voltage
  - entity: sensor.solax_inverter_current
  - entity: sensor.solax_inverter_power
  - entity: sensor.solax_pv1_voltage
  - entity: sensor.solax_pv2_voltage
  - entity: sensor.solax_pv1_current
  - entity: sensor.solax_pv2_current
  - entity: sensor.solax_inverter_frequency
  - entity: sensor.solax_inner_temp
  - entity: sensor.solax_run_mode_template
  - entity: sensor.solax_pv1_power
  - entity: sensor.solax_pv2_power
  - entity: sensor.solax_pv_total_power
  - entity: sensor.solax_battery_voltage
  - entity: sensor.solax_battery_current
  - entity: sensor.solax_battery_power
  - entity: sensor.solax_charger_board_temperature
  - entity: sensor.solax_charger_battery_temperature
  - entity: sensor.solax_charger_boost_temperature
  - entity: sensor.solax_battery_capacity
  - entity: sensor.solax_battery_energy_charged
  - entity: sensor.solax_bms_warning
  - entity: sensor.solax_battery_energy_discharged
  - entity: sensor.solax_battery_state_of_health
  - entity: sensor.solax_inverter_fault
  - entity: sensor.solax_charger_fault
  - entity: sensor.solax_manager_fault
  - entity: sensor.solax_measured_power
  - entity: sensor.solax_feed_in_energy
  - entity: sensor.solax_consumed_energy
  - entity: sensor.solax_eps_voltage
  - entity: sensor.solax_eps_current
  - entity: sensor.solax_eps_va
  - entity: sensor.solax_eps_frequency
  - entity: sensor.solax_energy_today
  - entity: sensor.solax_energy_total
  - entity: sensor.solax_battery_temperature
  - entity: sensor.solax_solar_energy_total
type: entities

Let me know how you get on and if you find out what some of the unknown values mean / do.

9 Likes

Could the Modbus commands for controlling the inverter (battery charge/discharge) be found?

1 Like

@battman

Glad someone has made use of my efforts to connect to the SolaX Inverters over Modbus.

I’m not sure if you used the linked solax package or the most up to date one from my GitHub I have corrected a few values and added a couple of extra Inverter States.

I do want to support battery control for two reasons.

  1. I don’t want to discharge my house battery on the rare occasion I need to charge my car at home (Luckily we have about 30 Chargers at work, so only have to top up at home once in a blue moon)
  2. I am interested in the Octopus Agile Tariff, where you can actually get paid to use energy when there is grid surplus. So I want to be able to tell the inverter to charge the battery off the grid.
    Also to dump energy into my Car. Might as well get paid to charge my car!

Last time I tried to write to Modbus registers it failed. But I think there was a bug in the Modbus implementation on HA where you were forced to provide slave information. Even though in this setup there isn’t a slave. I have looked at the code again and it looks like this has been removed?

I will try again in the next few days when we actually get some sun.

From my understanding you can write an int16 number to Register: 81 it accepts 0-65536 this controls the discharge from the battery.

If you write 1 to Register: 146 you tell the Inverter to Charge from the Grid.

Although if the Inverter has gone to sleep during the night as the battery is flat you may need to wake the inverter up by writing 1 to Register: 144

As soon as I get round to testing this out I will update my GitHub and this thread.

If anyone is interested in Octopus Energy I have a referral link where we both get ÂŁ50 credit.
They have normal Tariffs, Cheaper energy during the night for EV owners and also a Tariff that tracks the whole sale price and can pay you to use Energy! If there is surplus grid power.

i’m glad i found this post.
i’m currently busy setting up two solax inverters on my hassio. Both of them are connected to my network via the pocket LAN adapter. I’ve tried scanning them with nmap but it says all the ports are closed. i tried getting modbus to work but since all the ports are closed i cant.

Does anyone know how i can connect to my inverters?

Tim

For me only an intense Nmap scan would show up port 502. A normal scan wouldn’t show it.

Do you have an RS485 port on your inverter?
It’s probably behind the lower cover.

What are the exact Models you have?

@wills106

Thanks for the quick reply, i tried an intense scan but still the same result.
I have a RS485 but nothing is connected to it.
its a x1-3.3, the other one i dont know exactly but my main focus is the x1-3.3

You will have to try a RS485 - USB cable
You can get RS485 to Ethernet boxes but they are about ÂŁ50 on Amazon.

Then replace:

modbus:
  name: SolaX
  type: tcp
  host: ip_address
  port: 502

with

modbus:
  name: SolaX
  type: serial
  method: rtu
  port: /dev/ttyUSB0
  baudrate: 9600
  stopbits: 1
  bytesize: 8
  parity: N

You may have to play around with the baudrate to see what it uses.

Is threre no other way i can access the log data from the webserver?

Have you not tried the SolaX component in HA?

Yes i tried but without succes.
This is the message in HA when i reboot the system.

image

It says connection refused so there is something going on but i dont know what.

The SolaX component uses port 80 (webserver), but it isn’t open.

I don’t have a PocketLAN or PocketWiFi so can’t really offer any help.

You might have better luck with raising a ticket https://github.com/squishykid/solax

Can’t you get an Ardunino or ESP to the inverters and use the Modbus connection?
It looks like ESPHome supports ModBus looking at the source code. But I can’t find any documentation for it?

@battman

I have just uploaded a test version of my package solax_test.yaml into my experimental folder.
I believe you have an X3 model, so I am guessing you are on 3 Phase electrics?
Hopefully I have added in the extra power info for each phase.

Could you please test it out and let me know if the values look ok. I might need to change the precision around etc. So instead of 115v it might show as 11.5v etc. Just rename your old file to solax.yaml.old or move it out of the way somewhere.

@wills106

I indeed have Solax X3 Hybrid inverter and 3 T63 battery modules for total of 18.9 kWh. I installed the new solax.yaml but I do not see the 3 phase badges, and of course no data. I must be doing something wrong but what?

Are they not under Developer Tools / States?

I have not updated the lovelace example yet.

Should be something like:

sensor.inverter_phase_r_current
sensor.inverter_phase_r_frequency

etc

@Tim1739

I have inverter connected by LAN and port 502 is definitely operating. Pocket WLAN is different from LAN and it could be that there is no access to ports. Using RS485 port in the inverter could be a solution then but maybe in this case it would be better to connect just a LAN cable?

In the manual it is written that inverter communicates with the BMS using CAN protocol. BMS control batteries using RS485. Different cable arrangement is used for the CAN and RS485.

I do have CAN and RS485 box like this one

My initial idea was that I will connect it to the CAN and RS485 sides and try to see what is going on.
Not being an expert I do not know if connecting external device to those buses is fully safe. Will idea is of course much better but I wonder how it would be possible to read the status of individual battery modules.

Even without Lovelace I was able to see sensor badges for different parameters. Oh, I have forgotten that now I am getting one error badge Badges

By the way, I exchanged several mails today with Sx customer service asking about interfaces for home automation. They refuse to provide them hiding this by saying there is really no access to the internals:).

Do you manually setup Lovelace or let HA / HASSIO do it’s own thing?

You are best looking in Developer Tools / States like I mention.
Your entity Not Found is probably “SolaX Solar Energy Total” which was register 112 in my first version. I nether got a value from register 112.

I believe it’s only used on the X3 / 3 Phase inverter.

register 112 should hopefully be “Inverter phase S Power”

Yes, you wont get any help from SolaX! Even though in their earlier Inverter Manuals it mentions connecting RS485 upto a PC for monitoring etc…

Another piece of information. There is a company downunder named Batrium which offers hardware and software for people which are making their own batteries. This company company apparently has NDA with Sx and their stuff can operate with Sx inverter, maybe some useful information can be gleaned from this:

How is your lan cable connected to the inverter? Directly into the rs458 port?