Modbus binding with Sunny Boy SMA inverter

Look in the excel sheet I´d link to… Sometimes you need to read a different register to get the “right” power reading. It can be a bit of a pain to find the correct one to read… But a fast look at the sheet, I believe these are the ones you should be reading:

30775	Power      	W	S32	FIX0	RO		
30777	Power L1	W	S32	FIX0	RO		
30779	Power L2	W	S32	FIX0	RO		
30781	Power L3	W	S32	FIX0	RO		

FYI: https://github.com/openhab/openhab-addons/pull/6331#issuecomment-576666298

Btw, the Excel sheet says nothing about the length of the numbers. Or is there a standard ?

I have added another register. Now I have those strange values again after an OpenHAB restart. I’m suspecting my SMA inverter.

They have to fit into Modbus 16-bit registers/words. Looks to me like this SMA generally uses two words e.g. 32-bit. That still leaves a choice of integer, signed, floating point formats. There’s no way to guess that and you must find out from maker’s docs.

If only we knew what registers you were looking at … need a bit to work with, here.

Markus, what has this got to do with modbus for SMA inverters?

1 Like

SunSPEC is a vendor agnostic protocol. I would expect you could use this with SMA inverters, too.

The Excel sheet tells you the format. But not the length… Ususally it´s 4. But otherweise just give it a shot, play around with it. Its is written in the General Modbus Docs from SMA (somewhere). But as far as I recall it´s not specific to each model and register. (Its a huge document).

Here is my Things file for my main SMA inverter model STP 6000 TL-20… It looks like you can use most of the same registers for your inverter.

Bridge modbus:tcp:inverter1 [ host="10.4.28.248", port=502, id=3, connectMaxTries=3] {

// SMA Inverter Device Type
	Bridge poller DevType [ start=30053, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data DevType [ readStart="30053", readValueType="int32" ]
	   	 
  	 }

// SMA Inverter Status
	Bridge poller SMA_Status [ start=30201, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data SMA_Status [ readStart="30201", readValueType="uint32" ]

  	 }

// SMA Inverter Grid_Contactor
	Bridge poller Grid_Contactor [ start=30217, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data Grid_Contactor [ readStart="30217", readValueType="uint32" ]
	    
  	 }

// SMA Inverter Day Yield
	Bridge poller Day_Yield [ start=30517, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data Day_Yield [ readStart="30517", readValueType="uint64", readTransform="JS(divide1000.js)" ]
	    
   	 }

// Total Yield
	Bridge poller Total_Yield [ start=30529, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data Total_Yield [ readStart="30529", readValueType="uint32", readTransform="JS(divide1000.js)" ]
	    
 	 }

// SMA Inverter Power Section West
	Bridge poller power_a [ start=30773, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data power_a [ readStart="30773", readValueType="int32", readTransform="JS(smalimit.js)" ]
	   	 
  	 }

// SMA Inverter Power Total 
	Bridge poller Active_Power [ start=30775, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data active_power [ readStart="30775", readValueType="int32", readTransform="JS(smalimit.js)" ]
	    
  	 }

// SMA Inverter Power Section East
	Bridge poller power_b [ start=30961, length=4, refresh=5000, type="input" ] {
	    
	    	 Thing data power_b [ readStart="30961", readValueType="int32", readTransform="JS(smalimit.js)" ]
	   	 
   	 }

// SMA Inverter Operation
	Bridge poller SMA_Status_Operate [ start=40029, length=4, refresh=5000, type="holding" ] {
    
	    	 Thing data SMA_Status_Operate [ readStart="40029", readValueType="uint32" ]
	    
   	 }

}

Notice, I have two sets of solar panels. I have them named power_a and power_b.
You device can only handle one sets of panels, which is register 30773 according to the Excel sheet for your inverter…

You need to provide us with some help here. Show us which registers and how you have added it.
(Ie show us your things files, screendump from PaperUI / whatever you use).

Also - Be aware, sometimes modbus is very strange. If you make changes and it looks strange afterwards, it´s either due to there is an error somewhere, or the cache has screwed up… You´ll need to clear cahce and restart… Its a pain in the butt! After running into this issue a few times, you´ll learn to do the things right first time :grin: (I have struggled with this quite a few times… Making sure everything was good, Brigde and poller are online, but I got no data… Sometimes it can help restarting the modbus binding in Karaf consol insted of cleaning cache and restart, which is another pain in the butt for openhab).

Ahh okay… I wasn´t aware of that… Sorry, and nice to know.

Hi Kim,
This is my Things file:

Bridge modbus:tcp:SMAinverter [ host="192.168.178.130", port=502, id=2 ] {

// SMA SunnyBoy Device Type 30053 Device Type
     Bridge poller DevType [ start=30053, length=4, refresh=5000, type="input" ] {
        Thing data DevType [ readStart="30053", readValueType="int32" ]
     }

// SMA SunnyBoy Device Type 30057 Serial Nr
     Bridge poller SerialNr [ start=30057, length=4, refresh=5000, type="input" ] {        
        Thing data SerialNr [ readStart="30057", readValueType="int32" ]
     }

}

This is my items file:

Number DevType     "DeviceType [%d]"   <keyring>  { channel="modbus:data:SMAinverter:DevType:DevType:number" }
Number SerialNr    "Serienummer [%d]"  <keyring>  { channel="modbus:data:SMAinverter:SerialNr:SerialNr:number" }
Number SolarPower  "Vermogen [%.0f W]" <sun>      { channel="modbus:data:SMAinverter:SolarPower:SolarPower:number" }

I rebooted my Raspberry3B with OpenHAB. Device ID is now 4294967295
SolarPower is not yet present in my sitemap. First, I like to be succesfull with a simple field like the DeviceType.

Your things file looks good… Did you try restart the modbus binding i Karaf console?

No, I’m not familiar with that. I thought that restarting my RaspberryPi was sufficient.

I strongly advise giving every one of your Things a different “name” (UID)
Duplicate names lead to tears in the end.

I think in fact it is not too much of disaster for Bridge <> Data things, but get in the habit. Because dupe Bridge or data UID will not work properly, no matter if they belong to different “parents”

Hmm, this is the first time I hear this…I thought they should be the same?

OK, Thanks.

It’s already done. Better safe than sorry. Also modified my items file with the modified channels.
Bridge poller is now named as ‘sma+registernumber’ as you can see in my screenshot of Paper UI. Modbus Data and Pollers are all online.

Been added to the docs within the last year. You cannot mess up using PaperUI, but xxx.things files will allow you to make the error. The consequence is “weird” behaviour because you’re never sure which Thing definition is “live”.

Okeydoke, I guess the Poller (s?) are on another screen.
What does the data look like now, can we see events.log initial update?

Maybe thats what I was experience when I ran into the troubble and had to restart modbus binding several times?

Pollers are also online. See screenshot.

Logfile shows incidentally a reading error, once in an hour or so. Perhaps I have to clean the cache and restart the modbus binding. But I don’t know how to do this.

In basic UI, you can see the strange values. I have added the solar power.
When initializing the things, they are mentioned in te log-file

Error in the logfile.

I studied the documentation about the console. I stopped and started the modbus binding.

This is wat appeared in the logfile:

Does it work now then?

You first log (previous post) indicate there is some serious connection problem.
Your next log (after restarting the binding) shows everything is good to go…

If the connection problems appear again, you might want to check your ethernet cabel.