Modbus binding with Sunny Boy SMA inverter

This is what happens.

2020-10-27 10:59:37.496 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.modbus-2.5.9-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.modbus [313]
  Unresolved requirement: Import-Package: org.openhab.io.transport.modbus
    -> Export-Package: org.openhab.io.transport.modbus; bundle-symbolic-name="org.openhab.io.transport.modbus"; bundle-version="2.5.9.202009100355"; version="2.5.9"; uses:="org.eclipse.smarthome.core.library.types,org.eclipse.smarthome.core.types,org.openhab.io.transport.modbus.endpoint"
       org.openhab.io.transport.modbus [314]
         Unresolved requirement: Import-Package: org.apache.commons.pool2; version="[2.8.0,3.0.0)"
  Unresolved requirement: Import-Package: org.openhab.io.transport.modbus.endpoint
    -> Export-Package: org.openhab.io.transport.modbus.endpoint; bundle-symbolic-name="org.openhab.io.transport.modbus"; bundle-version="2.5.9.202009100355"; version="2.5.9"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]
2020-10-27 10:59:37.510 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.io.transport.modbus-2.5.9-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.transport.modbus [314]
  Unresolved requirement: Import-Package: org.apache.commons.pool2; version="[2.8.0,3.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Since I cant upgrade to openhab 2.5.10, I´m a bit stucked.

Make sure you have deinstalled Modbus binding in PaperUI.
Stop openHAB.
Remove the jar from /addons.
Restart.
Upgrade to 2.5.10

1 Like

Ahh now I get it…
You say due to the modbus jar is in the addons folder, openhab cant upgrade?

I´m so sorry, I totally misunderstood that. I will give it a shot asap.

Manage to get openhab updated to 2.5.10 now. And you were right. I had to remove the addons for openhab to update.
Now I´m at modbus 2.5.10, but I get tons of these warnings I didnt have before:

2020-11-05 21:30:48.237 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusReadRequestBlueprint@a47102[slaveId=30,functionCode=READ_INPUT_REGISTERS,start=200,length=23,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: SocketTimeoutException Read timed out [operation ID dfcc5012-66f8-4cce-969f-02a1a38e6c79]

Failed 1, 2 and 3, then the things goes offline, few seconds after it goes online again. And it starts all over.
This happens to all my modbus devices :frowning:

EDIT: Seems to happen to my Nilan device, (the ethernet tcp gateway only).
EDIT again… Also happens to me SMA devices.

Who knows. A failure of TCP communication; wrong IP, wrong port, wrong network, wrong domain, cable unplugged, remote device too busy, allowing no further connections, disabled. There really isn’t much to see at openHAB end in a “no response” situation.
Start with a basic ping I should think.

But I didnt change anything in the setup, except from updating openhab and the modbus binding to 2.5.10.
All settings are still the same.

I can ping and connect to the USR-TCP232-410S gateway fine.
My ping/enter my SMA devices fine as well.

This really seems to be an issue with the modbus 2.5.10 binding/transport

Okay. It works for other people. Let’s go round again, and verify at the console which modbus packages you now have installed.
Then perhaps a sample of a failing Bridge and one its poller configurations, and the error messages to go with that.

Hmm… it seems like I can get my SMA devices to run just fine. But as soon as I enable the USR gateway for the Nilan (RS485 interface). It mess up. I have to stop openhab, clear cache and restart openhab again, to get it to stop polling the USR device, even though I have disabled the thing…

Anyway, since this is not an SMA issue, I´ll create a new post in the modbus thread. I´ll tag you from there.

Hi Pjotr500

I have a sunny boy 1.5 but I do not manage to connect to it via modbus. Which ip adress do you use for the modbus connection?

Br
Gustav

Hi Gustav,

Sorry for my late answer, I don’t look often on this forum lately.
I’m not sure what you exactly asking. I use an internal IP-address within my home network.
Perhaps you mean the registers ?

I have OpenHAB recently updated to 2.5.10 without issues. Modbus is communicating properly since the issues mentioned in version 2.5.7

Kind regards,
Pieter

Hi Pieter

Solved the issue by using an ethernet cable directly connected to my sma sunny boy. I used WLAB when I posted this message as I ä could not establish a connection to my SMA sunny boy.

Br
Gustav

Den lör 28 nov. 2020 20:06Pieter via openHAB Community <bot@community.openhab.org> skrev:

has anyone tried to set the output power ? Is it data block 40268 (Setting for maximum output active power (WMax) ? What would be the syntax for this ?

Thank you so much for these informations! It works perfect on my side, just with copy and paste :slight_smile: I just needed to install the map transformation within the openhab 3 ui.

I have just one Question. I am searching for another value… The Total consumption value of my house. I could not find an option in Modus, neither in the webguis of the inverters and of the energy meter. But in the webgui of SMA or in the iOS App, there is the consumption displayed. Someone knows, where to get that value? Or do we have to calculate it in a way, with our known values? Perhaps someone has a good idea on that.

Dear Alaub81,
fighting myself to get my Sunnyboys connected I might be able to help you.
As you mentioned that your devices know about your total house consumtion I believe you have a sunny home manager installed? If so, try to find the preconfigured binding (the only one in the list if you look for “SMA”)

Once this binding is installed, the SHM will show up in your inbox, ready to install itself with a mouseclick…

Dear All,
thank you very much for this valuable conversation.
I tried so many things, but didn’t succeed to get connected although I already mastered to connect and read the right registers with help of a labview code.
Let me sum up my knowledge so far, since it might give a new starting point withing this thread that is filled with so many useful information already:

  • The registers are layed open in the latest SMA-modbus-documentation: (https://Device-specific Modbus adresses - Photovoltaikforum)
  • this time both is included - 30000-values (SMA-proprietary) AND 40000 (Sunspec).
  • a bit unclear is whether to use UNIT ID 2, 3 or 126. Different sources give different answers here. (using my labview code I must insert 126 to receive correct values from my SB2.5-1VL-40 )
  • Starting with this insights, I tried to see values through OH3, but never succeeded. IP is set correct and the inverter is answering on port 502, I could make sure.
    Copying differend, slightly adopted “.things” from above in this thread sometimes lead to new entries within the things group, sometimes not. If they appeared, the items are even somtimes green “online”. But I never got the right values.
  • might this be due to the modbus bindings I installed in the beginning but didn’t work (e.g. the generic “SinglePhaseInverter”? - I believed this should do since it follows the sunspec register-definitions)
  • I did also not find a useful manual how to get rid of a binding, once it was installed!?

Any help highly appreciated!!

Stepping in house outomation with a lot of photovoltaic knowledge my future ideas (once I get the base work done): binding in the EV-Charging station as well, offering opportunities as e.g.

  • priorisation of one or the other station (in case of two)
  • giving the User the choice to choose whether first charge the car(s) or better the battery to come over the night
  • all this and maybe more included in this great hause-dashboard called openHAB
    See U!
    Ansgar

No, I do not have the home manager, I only have the energy meter. And there I already have installed the binding. It works, but there is no total consumption value.

sorry for the late reply on this.
Unfortunatly you cant. You need to calculate it yourself. If you have the SMA energy meter, then you can get the current usage on each phases. Thats probably the best option.

Energy Meter will tell you the current (consumption) of each phases, Then you just have to calculate it to kWh´s (energy) :smiley:

Check your openhab log to make sure you get answers from the registers (channels) you´ve been adding.

In generel: Start simple. Modbus is not complicated, but it´s very easy to loose overview when dealing with many channels (things).
Make sure you have the correct registers. And know what data to expect to receive.

This is probably the best advices I can give.

1 Like

thanks for the answer I calculated it in that way:

  val Number TotalPower = (inverter1ActivePower.state as DecimalType
    + inverter2PreBatDischarge.state as DecimalType
    + inverter1PowerDrawn.state as DecimalType
    - inverter2PreBatCharge.state as DecimalType
    - inverter1PowerGridFeedIn.state as DecimalType)
  if ( TotalPower >= 0 ) {
    TotalPowerConsumption.postUpdate(TotalPower)
  }

But I will try your solution, too :slight_smile: