openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[modbus] binding malfunction with SMA solar inverter #5347

Closed Pinksheepxx closed 3 years ago

Pinksheepxx commented 5 years ago

I have SMA Tripower 5000TL solar inverter and I would like to collect yield data by using speedwire/tcp modbus connection. After pulling data, I would like to write it in Influxdb and view it on Grafana. I also would like to use yield data to control other appliances.

Current Behavior

I have tested modbus connection with RMMS and I could get right values by using input register number and varying length. Some times correct index number and length 1 do not give right value in RMMS.

I configured modbus binding and I could get some nonsense value using it. There has been topic about this same problem with openhab1 modbus binding. But I could develop solution using those observations.

Is there solution for this modbus communication error for openhab2 modbus binding? Or is there something else that I could not @@comprehend?

Config:

Things:

Bridge modbus:tcp:localhostTCP      [ host="192.168.0.24", port=502, id=3, connectMaxTries=3, connectTimeoutMillis=2000] {
    Bridge poller inputRegisters    [ start=529, length=7, type="input", refresh=1000] {
        Thing data daily_yield      [ readStart="530", readValueType="uint32"]
// 30531 = Total AC energy fed on all line conductors
        Thing data total_yield      [ readStart="534", readValueType="uint32"]
// 30535 = Energy fed in on the current day all line conductors

Items:

Number daily_yield1 "Yield: [%.1f kWh]" <tuotot> { channel="modbus:data:localhostTCP:inputRegisters:daily_yield:number" }
Number total_yield1 "Yield: [%.1f kWh]" <tuotot> { channel="modbus:data:localhostTCP:inputRegisters:total_yield:number" }

Log:

2019-03-31 15:38:35.805 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'default.things'
2019-03-31 15:38:36.229 [INFO ] [rt.modbus.internal.ModbusManagerImpl] - Unregistering regular poll task BasicPollTaskImpl@b4b342[request=ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@15ef76e[slaveId=3,functionCode=READ_INPUT_REGISTERS,start=529,length=7,maxTries=3],endpoint=ModbusTCPSlaveEndpoint@154fed3[address=192.168.0.24,port=502],callback=org.openhab.binding.modbus.internal.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator@f0d30846] (interrupting if necessary)
2019-03-31 15:38:36.236 [INFO ] [rt.modbus.internal.ModbusManagerImpl] - Poll task BasicPollTaskImpl@b4b342[request=ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@15ef76e[slaveId=3,functionCode=READ_INPUT_REGISTERS,start=529,length=7,maxTries=3],endpoint=ModbusTCPSlaveEndpoint@154fed3[address=192.168.0.24,port=502],callback=org.openhab.binding.modbus.internal.handler.ModbusPollerThingHandlerImpl$ReadCallbackDelegator@f0d30846] canceled
==> /var/log/openhab2/events.log <==
2019-03-31 15:38:36.250 [hingStatusInfoChangedEvent] - 'modbus:poller:localhostTCP:inputRegisters' changed from ONLINE to OFFLINE
2019-03-31 15:38:36.262 [hingStatusInfoChangedEvent] - 'modbus:data:localhostTCP:inputRegisters:total_yield' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2019-03-31 15:38:36.270 [me.event.ThingUpdatedEvent] - Thing 'modbus:poller:localhostTCP:inputRegisters' has been updated.
2019-03-31 15:38:36.283 [hingStatusInfoChangedEvent] - 'modbus:data:localhostTCP:inputRegisters:total_yield' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2019-03-31 15:38:36.304 [me.event.ThingUpdatedEvent] - Thing 'modbus:data:localhostTCP:inputRegisters:total_yield' has been updated.

Hardware and software:

SMA STP Tripower 5000TL, firmware: 02.56.03.R Raspberry Pi 3B+, rev 1.3 openHAB 2.4.0-1 modbus binding installed few days ago from paper UI (2.4.0)

ssalonen commented 5 years ago

The related openhab1 issue https://github.com/openhab/openhab1-addons/issues/4931

As discussed in the old binding issue, this is issue with the device, not the binding. Workaround has been discussed there as well.

ssalonen commented 5 years ago

@Pinksheepxx have you had time to look into my previous response? Do you agree this might be the case?

ssalonen commented 3 years ago

Further analysis in the community forum show how the message is broken/split on a tcp level:

https://community.openhab.org/t/modbus-binding-with-sma-inverter-missing-lower-byte/119467/16

This again sheds more insight into to the issue with the actual device SMA/Sunnyboy inverter .

I have asked user to test with https://github.com/openhab/openhab-core/pull/2284. It might help here as well even though what we see here is not ip fragmentation.

ssalonen commented 3 years ago

This seems to be finally resolved in https://github.com/openhab/jamod/pull/13#issuecomment-824082856