Modbus binding with Sunny Boy SMA inverter

Hello,
I know there are many topics about this, but with all information in other posts (new+old) I still can’t get openhab to read actual data from my inverter (Sunny Boy SMA).
In the inverter settings the modbus is enabled. The Modbus binding is installed.

The readout is “-NaN” except the “Actual Power” is always fixed to 2147483648.

Any help appreciated.
Hans

modbus.things :

Bridge modbus:tcp:localhostTCP [ host="10.0.0.78", port=502, id=2 ] {
    Bridge poller inputRegisters [ start=30775, length=2, refresh=1000, type="input" ] {
        Thing data input30775 [ readStart="30775", readValueType="uint32" ]
    }
    Bridge poller inputRegisters [ start=30517, length=4, refresh=1000, type="input" ] {
        Thing data input30517 [ readStart="30517", readValueType="uint64" ]
    }
    Bridge poller inputRegisters [ start=30513, length=4, refresh=1000, type="input" ] {
        Thing data input30513 [ readStart="30513", readValueType="uint64" ]
    }
    Bridge poller inputRegisters [ start=30783, length=2, refresh=1000, type="input" ] {
        Thing data input30783 [ readStart="30783", readValueType="uint32" ]
    }
}

modbus.items :

Number Input30775     "Actual Power W"  { channel="modbus:data:localhostTCP:inputRegisters:input30775:number" }
Number Input30517     "Daily Yield Wh"  { channel="modbus:data:localhostTCP:inputRegisters:input30517:number" }
Number Input30513     "Total MWh"       { channel="modbus:data:localhostTCP:inputRegisters:input30513:number" }
Number Input30783     "Volt V"          { channel="modbus:data:localhostTCP:inputRegisters:input30783:number" }

I can’t help with modbus, but could you format your post with code fences, please?

Bridge modbus:tcp:localhostTCP [ host=“10.0.0.78”, port=502, id=2 ] {

Are you confident about that id=2 ?
The docs suggest the default is generally 3.
But we’ll come back to that later.

Let’s start simple, and go step by step. There’s more than one Sunny Boy type but maybe this doc applies to yours.

Let’s make some Things, start with a new Things file and reboot for this test please.

Let’s poll some machine info to begin with, so we can be sure about addressing and get some confidence in your setup.
Modbus addressing has various conventions, starting at 0 or 1, organised into tables of 30000, 40000, etc. or not. So “30775” in some manufacturers manual may mean 30775 or 30774 or 775 or 774 in our binding settings.

Bridge modbus:tcp:hosttest [ host=“10.0.0.78”, port=502, id=1 ] {
   Bridge poller testing [ start=42109, length=4, refresh=10000, type=“holding” ] {
       Thing data smahold42109 [ readStart=“42109”, readValueType=“uint32” ]
       Thing data smahold42111 [ readStart=“42111”, readValueType=“uint16” ]
       Thing data smahold42112 [ readStart=“42112 readValueType=“uint16” ]
}

Note id=1 here, for this test.
Note 10 sec polling, as per manual.
Note mixed value types.
I’m expecting to read some serial number then two ID numbers like 126 and 3

Number testA “serial” { channel=“modbus:data:hosttest:testing:ismahold42109:number” }
Number testB “sunspec” { channel=“modbus:data:hosttest:testing:ismahold42111:number” }
Number testC “id” { channel=“modbus:data:hosttest:testing:ismahold42112:number” }

EDIT - typo above, should be smahold32109 etc. not isma…

Hi @SuysH

On SMA inverters you need id=3

I have it running - check out my config

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


// 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(divide1000.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(divide1000.js)" ]
	    
	   	 
	   	 }

// 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 Total
	Bridge poller Active_Power [ start=30775, length=4, refresh=5000, type="input" ]

		 {
	    
	    	 Thing data Active_Power [ readStart="30775", readValueType="int32", readTransform="JS(divide1000.js)" ]
	    
	   	 	   	 }

// 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 Status
	Bridge poller SMA_Status [ start=30201, length=4, refresh=5000, type="input" ]

		 {
	    
	    	 Thing data SMA_Status [ readStart="30201", readValueType="uint32" ]
	    
	   	 	   	 }

// 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" ]
	    
	   	 	   	 }

// SMA Inverter Country Standard
	Bridge poller SMA_Country [ start=40109, length=4, refresh=5000, type="holding" ]

		 {
	    
	    	 Thing data SMA_Country [ readStart="40109", readValueType="uint32" ]
	    
	   	 	   	 }

// SMA Inverter GFDI
//	Bridge poller SMA_GFDI [ start=30769, length=4, refresh=5000, type="input" ]

//		 {
	    
//	    	 Thing data SMA_GFDI [ readStart="30769", readValueType="uint32" ]
	    
//	   	 	   	 }




}
1 Like

Which SMA inverter are you using?
I got two.
One Sunny TriPower 6000TL (Grid inverter).
And one SunnyBoy Storage 2.5 (battery inverter).
Then I have a SMA Energy Meter as well. But this one cant run modbus.

All my SMA devices are connected through LAN, but I cant get info from the inverters through LAN. The Energy Meter can prodvide most info via LAN.
The Battery inverter is connected to a LG chem Resu 10 Battery. And I think this is using the modbus interface. So I´m not sure if I can connect another modbus here.
The Grid inverter is only connected through LAN.

I have sunny tripower 8000TL and accessing modbus through the Lan interface.

huh?? Doesn´t it have both LAN and modbus (RS485) interface?

Modbus itself can be used over serial (RS485) or over TCP (LAN).

I don’t know which SMA units support what, though.

Yes the SMA has build in TCP/IP modbus gateway.

I mistakenly bought the SMS RS485 interface just to find out that it’s not supporting Modbus - the protocol is only accessible through their LAN interface.

Hi @rossko57
Thanks for your reply. I did your initial test, but without result. The items don’t have any values.
When I look via PaperUI all the modbus Things are “online”
The log after reboot don’t show any errors.
I have a SMA Sunny Boy 3.6. Model SB3.6-1AV-41 (Newly installed since 3 weeks) connected via LAN to my network
Can I do any more tests to find the problem?

2019-09-15 10:29:12.695 [INFO ] [rt.modbus.internal.ModbusManagerImpl] - Modbus manager activated
2019-09-15 10:29:33.607 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'modbus.items'
2019-09-15 10:29:51.434 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'modbus2.things'
2019-09-15 10:29:52.138 [.ItemChannelLinkAddedEvent] - Link 'testC-modbus:data:hosttest:testing:ismahold42112:number' has been added.
2019-09-15 10:29:52.150 [.ItemChannelLinkAddedEvent] - Link 'testB-modbus:data:hosttest:testing:ismahold42111:number' has been added.
2019-09-15 10:29:52.153 [.ItemChannelLinkAddedEvent] - Link 'testA-modbus:data:hosttest:testing:ismahold42109:number' has been added.
2019-09-15 10:29:52.290 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42112' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2019-09-15 10:29:52.295 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42111' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2019-09-15 10:29:53.904 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42109' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2019-09-15 10:29:53.936 [hingStatusInfoChangedEvent] - 'modbus:tcp:hosttest' changed from UNINITIALIZED to INITIALIZING
2019-09-15 10:29:53.975 [hingStatusInfoChangedEvent] - 'modbus:tcp:hosttest' changed from INITIALIZING to ONLINE
2019-09-15 10:29:54.013 [hingStatusInfoChangedEvent] - 'modbus:poller:hosttest:testing' changed from UNINITIALIZED to INITIALIZING
2019-09-15 10:29:54.054 [hingStatusInfoChangedEvent] - 'modbus:poller:hosttest:testing' changed from INITIALIZING to ONLINE
2019-09-15 10:29:54.319 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42109' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2019-09-15 10:29:54.324 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42112' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2019-09-15 10:29:54.327 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42111' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2019-09-15 10:29:54.352 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42112' changed from INITIALIZING to ONLINE
2019-09-15 10:29:54.357 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42109' changed from INITIALIZING to ONLINE
2019-09-15 10:29:54.364 [hingStatusInfoChangedEvent] - 'modbus:data:hosttest:testing:smahold42111' changed from INITIALIZING to ONLINE

If you copy-pasted my suggestion, please note my typo in the Items’s channels which shows up in your log - I somehow put ismaxxxx instead of smaxxxx :roll_eyes:

If you fix that and nothing happens, turn on DEBUG logging as advised at the bottom of the docs

Hmm. Does this mean that it´s possible to run both LAN (TCP/IP) and Modbus at the same time on the LAN interface of the SMA inverters? If yes, whats required for this?

Yes - there is no requirements :blush:

May I ask (offtopic). How do you enter your Tripower inverter to configure it? For some reason I cant enter via browser (http) :frowning:
My Sunnyboy Storage inverter and my Energy Meter works fine though.

I use Sunny Explorer Tool to config it - as I recall you need the Admin login to configure it, not the basic user account.

Take a look at SMA site, if its the default password i’m sure that will be mentioned there.

Got it… (totally forgot about the Sunny Explorer application)…
Anyway - Before I mess everything up :laughing: I have a coupple of questions:

Will Webconnect still work with modbus (TCP server) activated? (I use Webconnect for SunnyPortal).
Should I enable both TCP and UDP for modbus to work? The modbus binding run TCP only, right?
Will modbus binding work, when I use modbus serial connection at the same time for the Nilan ventilation?

Yes. So far as I know, there is no standard for Modbus-UDP

Yes. It’s no different to multiple TCP devices or multiple serial port buses.

Thanks… I´ll give it a shot, and see how much I can manage to mess it all up… I´ll probably gona need the modbus docs, but I´ll start with Nanna´s example.
Also, since I have two inverters, I suspect one of them would need to change id? (I´ll start with my battery inverter, since it has most usefull information).

They will have different IP addresses in TCP, that is unique enough.

Ahh ofcouse…