Modbus binding with Sunny Boy SMA inverter

Just for documentation here …
I have installed the two inverters SMA Tripower 8 and SMA SunnyBoy Storage 3.7-10.

I uploaded all my configuration files to GitHub:

Also did a German documentation on my wiki:

2 Likes

thanks for sharing.
As a little feedback, get familiar with usingUnits of Measurement. Do not use [%s] everywhere in .items (but %d, %.0f etc). If you properly define the items with UoM you won’t need that [ ] part.

you are totally right :slight_smile:

could you please give me a hint how I could get it work without a state description [%.0f W]?
I changed the item type to Number:Power, but without [%.0f W] I don’t get the state description. I think the channel must support that, too?
Perhaps you have a tip for me, how to get that also working, so I could change my documentation.

You should be by default. But it depends where you are talking about it’s a complex question.
You can edit item metadata in UI (pattern field, same format ie [%.0f W])

fixed the Units of measurement stuff and also added somatic model tags to the items file. Update is pushed to GitHub and also documentation is updated.

Thanks again @mstormi for your feedback.

Thank you for the documentation.
I got this to work with my SMA SunnyBoy 2.5 on OH3
Looks like everything is working, except that the numbers don’t get divided.
Like for the “grid voltage phase L1” is displays 23123.00V instead of 231.23V
It looks like the smalimit100.js file is not used.
Could you help me with this?

Where did you put it?
Have you installed the JS transformation add-on?

That’s it, forgot those add-ons.
Now it works fine.
Thank you for the fast response.

Excellent work @alaub81 !

I have the same issue, and migrated to openhab3. The modbus is working but the values are off.
Does some one have this working with the modbus binding?

Yes I’m even selling an Energy Management System to use it.
You can download the demo and extract the config.

Thank you for the response, can you point me to the correct folder? I did download the demo but was unable to find the openhab folder.

Thanks!

Click System, Photovoltaik to select your inverter and the things/items will be created and appear in Main UI.

Thanks for all the input and the good documentation of the things and items.
But I’ve got one more question.
What about the decimal places? You use a int32 type. For things like daily total production there would be nice to see 10,252 kWh instead of 10kwh.

Is it possible to change it?! Any ideas or solutions?

Thanks

Hi Andreas,
thanks for your work.
I followed your documentation to communicate with my Sunny Tripower 6.0.
But unfortunately all things except the “SMA Inverter 1 Bridge” show : ERROR: Bridge
They seem to be on the wrong bridge. Do you know where this problem could come from?

Greetings Johannes

Stumbled on this topic today. Pure coincidence, I also have a Sunny Tripower 6 and I have the same problem as Jaunney. SMA Inverter 1 Bridge is online, all other give an error. I attached a screenshot. Not the complete list as my (laptop) screen is not big enough to show the whole list, but you get the idea…

Can you share error details? You can open up the thing by clicking it to see the details

This is the code for the working bridge:

UID: modbus:tcp:inverter1
label: SMA Inverter 1 Bridge
thingTypeUID: modbus:tcp
configuration:
  rtuEncoded: false
  connectMaxTries: 3
  timeBetweenTransactionsMillis: 60
  reconnectAfterMillis: 0
  port: 502
  timeBetweenReconnectMillis: 0
  host: 192.168.2.48
  connectTimeoutMillis: 10000
  afterConnectionDelayMillis: 0
  id: 3
  enableDiscovery: false

No problem there. But for instance ‘SMA Inverter 1 Active Power’ I get a bridge error.
Apparently it tries to connect to a non-existent bridge (or at least that is how I read the error) "SMA Inverter 1 Poller Power A and Total " :

UID: modbus:data:inverter1:power_a:active_power
label: SMA Inverter 1 Active Power
thingTypeUID: modbus:data
configuration:
  readValueType: int32
  readTransform: JS(smalimit.js)
  writeTransform: default
  readStart: "30775"
  updateUnchangedValuesEveryMillis: 1000
  writeMultipleEvenWithSingleRegisterOrCoil: false
  writeMaxTries: 3
bridgeUID: modbus:poller:inverter1:power_a

Nothing is editable since all data is coming from files. So it seems the files have to be edited, but where to begin…

Since I am new to this forum, I cannot reply anymore. So I’m editing a previous post, hope that will work…
SMA Inverter 1 Bridge is working. As far as I know this is the one that tries to connect to the SMA modbus. It appears to connect to the right IP, right port (502) and id (3).
However, in the log files there is indeed a warning about being unable to reach the ip:

2023-03-07 14:22:22.025 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Connect reached max tries 3, throwing last error: Connection refused (Connection refused). Connection TCPMasterConnection [m_Socket=Socket[unconnected], m_Timeout=3000, m_Connected=false, m_Address=/192.168.2.48, m_Port=502, m_ModbusTransport=null, m_ConnectTimeoutMillis=10000, rtuEncoded=false]. Endpoint ModbusIPSlaveEndpoint [address=192.168.2.48, port=502]
2023-03-07 14:22:22.028 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection TCPMasterConnection [m_Socket=Socket[unconnected], m_Timeout=3000, m_Connected=false, m_Address=/192.168.2.48, m_Port=502, m_ModbusTransport=null, m_ConnectTimeoutMillis=10000, rtuEncoded=false] for endpoint ModbusIPSlaveEndpoint [address=192.168.2.48, port=502]: Connection refused (Connection refused)
2023-03-07 14:22:22.030 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusIPSlaveEndpoint [address=192.168.2.48, port=502] -- aborting request ModbusReadRequestBlueprint [slaveId=3, functionCode=READ_INPUT_REGISTERS, start=30769, length=20, maxTries=3] [operation ID 325610d4-5496-4307-983f-8cd1535b8aee]

I don’t get this, but then again I’m far from being an expert :wink: .
Do I need to change something on the Inverter (timeout??), is my id incorrect? I see a slash in front of the ip (m_Address=/192.168.2.48), can that be a problem?
Edit2: Just found that I cannot login to the web interface of the SMA inverter. Most likely due to Openhab exceeding the max connection tries. I have deleted the SMA bindings altogether until I find what the problem is.

Still the same issue as described by arjena.

The “sub-bridges” such as “SMA Inverter 1 Poller Device Type” get me a COMM-Error:

COMMUNICATION_ERROR

Error with read: org.openhab.core.io.transport.modbus.exception.ModbusConnectionException: Error connecting to endpoint ModbusIPSlaveEndpoint [address=192.168.0.34, port=502]

The code of this poller looks like:

UID: modbus:poller:inverter1:DevType
label: SMA Inverter 1 Poller Device Type
thingTypeUID: modbus:poller
configuration:
  start: 30053
  length: 3
  refresh: 60000
  maxTries: 3
  cacheMillis: 50
  type: input
bridgeUID: modbus:tcp:inverter1