New Modbus openHAB 2.x binding, PaperUI configuration

Hi,

I have a huge problem to understand new 2.x Modbus binding.

With 1.x I had no problems but now I have. I try to understand new wave of openhab2 and PaperUI.

Is there any simple instructions how to get one Modbus register to be read from this new way of thinking…

What I have tried to do is to get only one temperature from Twido PLC with direct TCP connection from register %MW0.

How to configure an item from bottom to up with PaperUI? I hope that there are lots of people who understand new PaperUI way to configure openHAB instead of writing configurations via Notepad++

Thank you in advance!

OpenHAB is latest (2.4.1).

I have Modbus V2 working. I came from OpenHAB 1.0 so I’m used (and like) textual configuration.
In PaperUI is almost the same, but this is what I did:

modbus.things:

Bridge modbus:tcp:plc [ host=“192.168.1.195”, port=502, id=1 ] {
Bridge poller lampadas [ start=000, length=49, refresh=500, type=“holding” ] {

/*Anexos */

    Thing data LampCozAnexo [ readStart="000", readValueType="int16", writeStart="000", writeValueType="int16", writeType="holding" ]
  Thing data Lamp2VarAnexo [ readStart="001", readValueType="int16", writeStart="001", writeValueType="int16", writeType="holding" ]

Thing data Lamp1VarAnexo [ readStart=“005”, readValueType=“int16”, writeStart=“005”, writeValueType=“int16”, writeType=“holding” ]
Thing data LampFrentGarAnexo [ readStart=“003”, readValueType=“int16”, writeStart=“003”, writeValueType=“int16”, writeType=“holding” ]
//Thing data LampChurascoAnexo [ readStart=“004”, readValueType=“int16”, writeStart=“004”, writeValueType=“int16”, writeType=“holding” ]

Thing data TsxDiaSemana [ readStart=“014”, readValueType=“int16”, writeStart=“014”, writeValueType=“int16”, writeType=“holding” ]
Thing data TsxHoraAtual [ readStart=“016”, readValueType=“int16”, writeStart=“016”, writeValueType=“int16”, writeType=“holding” ]
Thing data TSXMesAtual [ readStart=“017”, readValueType=“int16”, writeStart=“017”, writeValueType=“int16”, writeType=“holding” ]
Thing data TSXAnoAtual [ readStart=“018”, readValueType=“int16”, writeStart=“018”, writeValueType=“int16”, writeType=“holding” ]

}
}

modbus.items:

Switch LampCozAnexo “Lâmpada da cozinha do anexo” (LampAnexos) {channel=“modbus:data:plc:lampadas:LampCozAnexo:switch”}
Switch Lamp2VarAnexo “Lâmpada 2 da varanda do anexo” (LampAnexos) {channel=“modbus:data:plc:lampadas:Lamp2VarAnexo:switch”}
Switch Lamp1VarAnexo “Lâmpada 1 da varanda do anexo” (LampAnexos) {channel=“modbus:data:plc:lampadas:Lamp1VarAnexo:switch”}
Switch LampFrentGarAnexo “Projetor garagem anexo” (LampAnexos) {channel=“modbus:data:plc:lampadas:LampFrentGarAnexo:switch”}
//Switch LampChurascoAnexo “Lâmpada churrasqueira” (LampAnexos) {channel=“modbus:data:plc:sinais:LampChurascoAnexo:switch”}

Number TsxDiaSemana “Dia da semana [%1d]” (gExt) {channel=“modbus:data:plc:lampadas:TsxDiaSemana:number”}
Number TsxHoraAtual “Hora actual [%1d]” (gExt) {channel=“modbus:data:plc:lampadas:TsxHoraAtual:number”}
Number TSXMesAtual “Mês actual [%1d]” (gExt) {channel=“modbus:data:plc:lampadas:TSXMesAtual:number”}
Number TSXAnoAtual “Ano actual [%1d]” (gExt) {channel=“modbus:data:plc:lampadas:TSXAnoAtual:number”}

Hope this helps.

João

João,

Thank you!

So you suggest that better way is still use textual way.

I also prefer that.

I just wonder why PaperUI has been developed.

For Modbus for example there is a good documentation to do it manually.

I tried with PaperUI but not get even one measurement.

I will try to do it with your example tomorrow!

KNX worked well, via textual configuration :slight_smile:

I thought that via PaperUI those configurations would be easier.

Hopefully someone who know could explain PaperUI configuration for things because as far as I know it has been developed for people who is not so familiar for textual configurations.

I think PaperUI configuration is important to grow members for this great platform but now it seems too complicated which is of course only my opinion.

PaperUI is great for technologies with “discovery”, like zwave. It does at least some of the work for you.

No chance of that kind of help with Modbus, which has zero self-identify capability.

1 Like

Yes rossko57, you are right!

Via PaperUI I configured easily Bindings like Astro and NTP which worked really well.

Now I have also Modbus working and that is made manually with the help of jcurado

If someone have similar problems to start, I will try my best to help.

Great community!

hi all
can you help me setut modbus binding with oh2
i try to setup SDM120 Modbus Single Phase Multifunction Energy Meter via RS485/ModBus
it works fine with python script

#!/usr/bin/env python
 
# Modbus uitlezen
# Apparaat: EASTRON SDM120 (KWh meter)
#
# Script gemaakt door S. Ebeltjes (domoticx.nl)

from __future__ import division
import pymodbus
import serial
from pymodbus.pdu import ModbusRequest
from pymodbus.client.sync import ModbusSerialClient as ModbusClient #initialize a serial RTU client instance
from pymodbus.transaction import ModbusRtuFramer

from pymodbus.constants import Endian              # Nodig voor 32-bit float getallen (2 registers / 4 bytes)
from pymodbus.payload import BinaryPayloadDecoder  # Nodig voor 32-bit float getallen (2 registers / 4 bytes)
from pymodbus.payload import BinaryPayloadBuilder  # Nodig om 32-bit floats te schrijven naar register

method = "rtu"
port = "/dev/ttyUSB0"
baudrate = 9600
stopbits = 1
bytesize = 8
parity = "N"
timeout = 1
retries = 2

try:
  client = ModbusClient(method = method, port = port, stopbits = stopbits, bytesize = bytesize, parity = parity, baudrate = baudrate, timeout = timeout, retries = retries)
  connection = client.connect()
except:
  print "Modbus connectie error / EASTRON SDM120"

def kwh(appid,reg1):

  data = client.read_input_registers(reg1, 2, unit=appid)
  print data.registers
  decoder = BinaryPayloadDecoder.fromRegisters(data.registers,Endian.Big) # endian=Endian.Little / endian=Endian.Big
  eastron_sdm120_kwh = round(decoder.decode_32bit_float(), 2)
  client.close()
  return eastron_sdm120_kwh

print "Voltage: ", kwh(1,0), "Volts"
print "Active Power: ", kwh(1,12), "Watts"
print "Current: ", kwh(1,6), "Amps"
print "Frequency: ", kwh(1,70),"Hz"
print "Active Enargy: ", kwh(1,342),"kWh" 

output :

Voltage:  [17267, 39322]
243.6 Volts
Active Power:  [17378, 45875]
453.4 Watts
Current:  [16405, 24642]
2.33 Amps
Frequency:  [16968, 0]
50.0 Hz
Active Enargy:  [17033, 36569]
68.78 kWh

but i have no idea how to setup .thing and .item files
via paperUI i just this info http://prntscr.com/n9rlrd but cant recieve same as from python script

Thank you in advance!