Solis Inverter Modbus integration

Hi all,

I am in the process of connecting to a Solis Inverter (SOL-3.0K-RAI-48ES-5G-AC) using modbus. I have managed to integrate with a few other devices for reading energy e.g. Single phase meters and other inverters, so little experience but I am having issues with the Solis.

This is some of what I have so far:

image

Snippets from config file

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

sensor:
- platform: modbus
  scan_interval: 5
  registers:
#Solis Inverter      

    - name: solisinvertertemperature
      hub: Hub1
      unit_of_measurement: °C
      register: 33093
      register_type: input
      count: 1
      slave: 3
      precision: 1
      data_type: uint
      scale: 0.1      
      
    - name: solisbattarysoc
      hub: Hub1
      unit_of_measurement: "%"
      register: 33139
      register_type: input
      count: 1
      slave: 3
      #precision: 1
      data_type: uint
      #scale: 0.1  
      
    - name: solisbatterychargecurrentlimitation
      hub: Hub1
      unit_of_measurement: A
      register: 33143
      register_type: input
      count: 1
      slave: 3
      precision: 1
      data_type: uint
      scale: 0.1
      
    - name: solisbatterydischargecurrentlimitation
      hub: Hub1
      unit_of_measurement: A
      register: 33144
      register_type: input
      count: 1
      slave: 3
      precision: 1
      data_type: uint
      scale: 0.1

The issue is that when reading other registries I am getting data back which I am not expecting. As seen below.

image

Both of the charge and discharge rates should be 50A and the hours and mins should just be integers between 0 and 60.

I have played with the data_type and also the count but they are listed as the same format within the modbus manual as registries I am reading correctly as above, (U16 or count:1)

With reviewing the Modbus manual from Solis it seems that the function code for the selection of requesters which is not working is 06H (6) not the same as the ones which work 04H (4)

So the question is, is there a way I can force the function code so I can test to see if this helps with reading the required registries.

Hope that’s understandable and thanks in advance.

EDIT: After talking with the manufacture they confirm that we need to be using function 6. However when reviewing the HA Modbus specification at Modbus - Home Assistant (home-assistant.io) it says that by default its using 6 for a single value and not 4! So I am not sure what’s happening and why I am getting any reading at the moment. Any insight from anyone would be appreciated!

2 Likes

Did you ever figure out the reason for the above and a fix? Maybe try reading the register without HA, with a laptop etc
Function 6 doesn’t make sense because that’s for writing a register
image

@sd_dracula/@boydo , not sure if this might be helpful, I have some python reading the modbus registers, largely thanks to a thread you and some others have that I’ve been following over on the OpenEnergyMonitor community
It’s very much a work in progress but here’s what I have so far: solis_5g_modbus.py · GitHub
My ultimate goal is to get this ported onto an esp8266 or similar that can replace the board inside the data logger to feed into HA without having to have cables running between the inverter and my HA setup. Will try and share to one of the threads on here as I make progress.

That’s helpful thanks.
I can read the values just fine via python from my laptop using an RS485 to usb adapter or with a pi zero, but when I plugged in the same USB adapter into the rpi4 that’s running my HA instance it doesn’t work.
It’s showing up as dev/ttyUSB0 in the device list and I tried your config.yaml from above but it just makes HA super slow to boot and it never gets any values for those registers, not sure why. Do I need to install any additional libraries?
In the logs it just says it expected 2 bytes but got back nothing (no activity on the usb adapter either)
Once I get the script to pull all the data I need might look at a TCP modbus adapter

By the way the new 340022 FW for the inverter can now set multiple charging schedules not just one.
Let me know if you get the writing of the registers to work :slight_smile:

Yes I managed it, I had not realized the importance of “holding” or “input” register type setting and how that affects the function code.

more details here on another thread here

Basically I had to change the register_type from “holding” to “input” to get the correct function code which in the case of Solis and the 33k range was function code 4 or 0x4.

Or in the example below changing it to “holding” gives function code 3 e.g. ‘0x1 0x3 0xa8 0x85 0x0 0x1 0xb5 0x83’

- name: Solis Time Chargeing Charge Current #U16
  hub: Hub1
  unit_of_measurement: A
  register: 43141
  register_type: holding
  count: 1
  slave: 1
  precision: 1
  data_type: float
  scale: 0.1

So at the moment I can read all the registries and pull all the data documented in the modbus manual. I can also update any single registers. e.g. min state of charge. So I can force it to charge but only up to 40% for some reason!

According to the manufacture you are meant to use the “Time-charging” discharge and charge times and rates to be able to force the inverter to charge and discharge at any time or rate.

Using write_register service I can set all of these registers individually but the inverter dose not respond to any changes! I have been advised to test writing multiple registers at once using function code 10, as per your manual snippet, to update the “Time-charging” registers as a group. But as far as I can see HA can only write using function code 6 for single registers or 16 for multiple.

So this is what I am working on at the moment and I am going to try node red and see if that works!

If anyone has success in forcing the inverter to charge over 40% or to discharge please let me know.

2 Likes

Sounds good, if you ever get to be able to fully control both charge and discharge please please let me know. :slight_smile:

Did you try a stand alone modbus app for writing the registers and does that work? If yes then HA is the issue
Also which USB adapter are you using to connect to your HA server? I have tried this one which works ok on my laptop/pi zero but nothing when connected to the pi4 with HA OS on it

@sd_dracula RE reading via HA I am sure I had a similar issue at one point just cant remember how I solved it. I would post all my config now but all the code is with a client (yes I know I should have back it up) will post it once I have it back.

Think I would check that you have the setup of the modbus right, something like

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

Yes that’s what I had for sure and ttyUSB0 was my adapter also.
Could be that the actual sensors were not set up right (didn’t quite match the HA modbus examples) so maybe share some of them once you have them so I can compare

Will defenatly share the code once I have it back.
The adaptor I am using is this one.

1 Like

Any guide on updating the FW? Do you have to have an update stick! eg. a usb with the FW on it? Where did you get the FW etc…
Thanks

Logged a support ticket with Solis and they pushed it manually to my inverter.
Hopefully that didn’t mess up the register numbers from their docs :slight_smile:

1 Like

Have you had any experience with this? I might try and see if there is a free modbus tool for windows and connect it up for testing.

Not with writing but played around with reading alright:
https://www.modbustools.com/quickstart.html

I had a similar issue with the stick I’m using, it works fine with a Mac or my Pi3 but won’t work with my synology NAS where I have HA running, I haven’t managed to get to the bottom of the issue annoyingly.

I’ll have to give this a go, multiple slots could be useful.

I think I have charge working, it didn’t seem to discharge to the grid though, I just tried again and it discharged to the grid, I think the inverter might’ve already been maxing out with solar earlier. For charge I set the times and set the storage control register:

# Charge between 1800-0800, discharge between 0800-1800
instrument.write_registers(43143, [18, 00, 8, 0, 8, 0, 18, 0])
# 33 = Self use mode
# 35 = Timed charge mode
instrument.write_register(43110, functioncode=6, signed=False, value=35)
1 Like

In terms of writing to the USB port - make sure that the user that is running HA has permissions on the created USB port - usually the easiest way is to add them to the Dialout group (i think thats the one) as it is given write access to the ports on Linux

In terms of the SYnology NAS - i assume you are running this in the Synology version of Docker ? You would have to do some messing around with the bridge network under Docker to give access to the USB port i believe.

Here is a hint re how to do this

Craig

1 Like

Did you ever get that yaml code for the HA config? Would like to try it out again on HA because maybe I can skip adding another pi :slight_smile:

sorry not yet, trying to recreate it as we speak :upside_down_face:

Thanks and an FIY some breaking changes were made to modbus in the HA release from today 2021.6: A little bit of everything - Home Assistant
Doesn’t look like a big change.

1 Like

Mark the above code was that from an automation? how are you running that code, is it from HA?

update: sorry just realized that you where using python to run that. I am not 100% on how you run that. I did see that you can run python scripts as services is that what you did? If not is it possible to run yours as a service as per following link? Python Scripts - Home Assistant (home-assistant.io)