Migrated openhab2 IEC 62056 21 Meter Binding

It looks like jar for stiebelheatpump inside :frowning:

upps wrong construction area :slight_smile:
try this one
https://drive.google.com/open?id=1H6GKOpIc281RAH58ylqjPONdihfOAoKT

Ok. Could you tell me step by step how can I check it

sure,
just replace the jar file in your /j62056/build/libs-all with the new jar file in link i shared with you.
then do
sudo ./j62056-reader -p /dev/ttyUSB0 -b 9600 -d 100 -t 5000 -v
as you did before and see if you still get data from the meter

i changed some code for the initial hand shake and changing the baud rate from the response message coming from the meter.
My meter creates some strange bytes. In the new code i addes some line to deal with these bytes.

If you get a responds as before these changes did not affect you meter

i have an identical output using origin and modified lib

new +++++++
DEBUG: Sending {“request message”: {“device address”: “”}}
DEBUG: Received {“identification message”: {“manufacturer ID”: “ISk”, “protocol mode”: “C”, “baud rate”: 9600, “meter ID”: “MT174-0001”, “enhanced ID/capability”: “”}}
DEBUG: Sending {“acknowledge message”: {“protocol control character”: “NORMAL”, “baud rate”: 9600, “acknowledge mode”: “DATA_READOUT”}}
DEBUG: Sleeping for : 100ms before changing the baud rate
DEBUG: Changing baud rate from 9600 to 9600
DEBUG: Received data message.
Received
{
“data message”: {
“manufacturer ID”: “ISk”,
“meter ID”: “MT174-0001”,
“enhanced ID/capability”: “”,
“data block”: {
“data set”: {“address”: “1-0:0.9.1255", “value”: “195723”, “unit”: “”},
“data set”: {“address”: "1-0:0.9.2
255”, “value”: “0171114”, “unit”: “”},
“data set”: {“address”: “1-0:0.9.4255", “value”: “0171114195723”, “unit”: “”},
“data set”: {“address”: "1-0:0.0.0
255”, “value”: “67638426”, “unit”: “”},
“data set”: {“address”: “1-0:0.1.0255", “value”: “2”, “unit”: “”},
“data set”: {“address”: "1-0:0.2.0
255”, “value”: “1.04”, “unit”: “”},
“data set”: {“address”: “1-0:0.2.2255", “value”: “”, “unit”: “”},
“data set”: {“address”: "0-0:C.1.0
255”, “value”: “67638426”, “unit”: “”},
“data set”: {“address”: “0-0:C.2.0255", “value”: “2”, “unit”: “”},
“data set”: {“address”: "0-0:C.2.1
255”, “value”: “1160926111417”, “unit”: “”},

old +++++++++++++++++
DEBUG: Sending {“request message”: {“device address”: “”}}
DEBUG: Received {“identification message”: {“manufacturer ID”: “ISk”, “protocol mode”: “C”, “baud rate”: 9600, “meter ID”: “MT174-0001”, “enhanced ID/capability”: “”}}
DEBUG: Sending {“acknowledge message”: {“protocol control character”: “NORMAL”, “baud rate”: 9600, “acknowledge mode”: “DATA_READOUT”}}
DEBUG: Sleeping for : 100ms before changing the baud rate
DEBUG: Changing baud rate from 9600 to 9600
DEBUG: Received data message.
Received
{
“data message”: {
“manufacturer ID”: “ISk”,
“meter ID”: “MT174-0001”,
“enhanced ID/capability”: “”,
“data block”: {
“data set”: {“address”: “1-0:0.9.1255", “value”: “195613”, “unit”: “”},
“data set”: {“address”: "1-0:0.9.2
255”, “value”: “0171114”, “unit”: “”},
“data set”: {“address”: “1-0:0.9.4255", “value”: “0171114195613”, “unit”: “”},
“data set”: {“address”: "1-0:0.0.0
255”, “value”: “67638426”, “unit”: “”},
“data set”: {“address”: “1-0:0.1.0255", “value”: “2”, “unit”: “”},
“data set”: {“address”: "1-0:0.2.0
255”, “value”: “1.04”, “unit”: “”},
“data set”: {“address”: “1-0:0.2.2255", “value”: “”, “unit”: “”},
“data set”: {“address”: "0-0:C.1.0
255”, “value”: “67638426”, “unit”: “”},
“data set”: {“address”: “0-0:C.2.0255", “value”: “2”, “unit”: “”},
“data set”: {“address”: "0-0:C.2.1
255”, “value”: “1160926111417”, “unit”: “”},

great news and many thanks for testing.
next step is to update the binding to the new library.
Hope to get some time on weekend

HI all,

i am actually working on to update to the new library.
Unfortunatly is facing issues with the rxtx library and can not open the serial port.
On command line everything works but not inside openhab

`Caused by: java.lang.NoSuchMethodError: gnu.io.CommPortIdentifier.open(Ljava/lang/String;I)Lgnu/io/CommPort;
    at org.openmuc.jrxtx.JRxTxPort.openSerialPort(JRxTxPort.java:54)
    at org.openmuc.jrxtx.SerialPortBuilder.build(SerialPortBuilder.java:166)
    at org.openmuc.j62056.Iec21Port.<init>(Iec21Port.java:270)
    at org.openmuc.j62056.Iec21Port.<init>(Iec21Port.java:47)
    at org.openmuc.j62056.Iec21Port$Builder.buildAndOpen(Iec21Port.java:243)
    at org.openhab.binding.iec6205621meter.handler.Iec6205621MeterHandler.read(Iec6205621MeterHandler.java:218)
    at org.openhab.binding.iec6205621meter.handler.Iec6205621MeterHandler.updateMeterData(Iec6205621MeterHandler.java:195)
    at `

I guess it could be a incompatibility of the nrjavaserial and the jrxtx wrapper

Any hints from somebody to get this resolved.

BR
peter

made some progress by moving the source from jrxtx and j62056 and compiled against nrjavaserial.
can now read but not stable in my case.
do not get stable condition in reading the periodically from the meter.
After first read the secondread ends in a timeout.
Not sure if this is a issure with my meter only

Hello, Peter
Any improovement?
I’am open for the tests.

It looks https://github.com/Gurux/gurux.serial.java very intresting

Is it possible to make a fork with a fixed rate?
May be change
public class Connection

private static int[] baudRates = new int[] { 9600 };
… and
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_7, SerialPort.STOPBITS_1, SerialPort.PARITY_EVEN);

would be enough for that?
Just for rs485 meters :slight_smile:
Thank you

hi vaslkov,

sorry was very much busy in the last month and did not really had time to
get the binding wokring in stable condition with the upgraded openmuc
library.
In the meantime i am able to receve data but the periodic load is not
stable and the serial port get blocked.
I assume that the code i took from the new library does in some cases not
properly release the serial port.

In the meantime i do have a new laptop and now i need to first get the
development environment again up and running.

I hope to have a bit more time during the christmas time.
enjoin christmas

Peter

Hello Peter
Any improovement?

Hello,

i am starting to use OpenHab 2.
My first intention was to readout my power-meter. It’s a “Iskra mt174”.
After some starting problems with the IEC62056-Meter bindings (installing by default the version 1.x bindings instead of the 2.x version), I think the binding in correct running.

This power-meter needs an init-string before it sends back the data.
In the OpenHab-logfile I get the message:

2018-05-13 20:34:38.094 [ERROR] [meter.handler.Iec6205621MeterHandler] - IOException while trying to read: Timeout while listening for Data Message
2018-05-13 20:34:38.150 [ERROR] [meter.handler.Iec6205621MeterHandler] - Could not get data from IEC 62056-21 meter connected to /dev/ttyUSB0.

With a short python script i have verified the connection to the power-meter:
"
# mt174read.py

import serial
import time

SERIALPORT = “/dev/ttyUSB0”
BAUDRATE = 300

ser = serial.Serial(SERIALPORT, BAUDRATE, serial.SEVENBITS, serial.PARITY_EVEN)

sendtxt = “\x2F\x3F\x21\x0D\x0A”
ser.write(sendtxt.encode())

time.sleep(0.5)
numberOfLine = 0

while True:
response=ser.readline()
print(response)
numberOfLine = numberOfLine + 1
if (numberOfLine >= 60):
break
ser.close()
"

My question:
Where can I set the initMessageBytes ?

If I change something via PaperUI: “Configuration -> Things -> Edit -> IEC 62056-21 Meter Thing”
I get an error message “Error 500: Internal error” and in the log file:
"2018-05-13 20:56:07.000 [ERROR] [st.core.internal.thing.ThingResource] - Exception during HTTP PUT request for update config at ‘things/iec6205621meter:meter:a678e2d0/config’
java.lang.NullPointerException: null
at org.openhab.binding.iec6205621meter.handler.Iec6205621MeterHandler.dispose(Iec6205621MeterHandler.java:152) [223:org.openhab.binding.iec6205621meter:2.1.0.201711092305]

"

directly writing into the configuration file “/etc/openhab2/services/iec6205621meter.cfg”
seems not successful to solve the problem.
"
meter.serialPort=/dev/ttyUSB0
meter.baudRateChangeDelay=0
meter.initMessage=\x2F\x3F\x21\x0D\x0A

"

Any hint’s ? :thinking:

Regards
Jens

In the meantime i have solved some problems…
Now Openhab get every 60 Sek Data from my mt174 meter:

2018-05-21 20:53:19.517 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: MT174-0001;;
2018-05-21 20:53:19.520 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:0.9.1*255;205221;
2018-05-21 20:53:19.522 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:0.9.2*255;1180521;
2018-05-21 20:53:19.525 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:0.0.0*255;66816007;
2018-05-21 20:53:19.527 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:0.0.1*255;66816007;
2018-05-21 20:53:19.530 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:0.1.0*255;26;
2018-05-21 20:53:19.532 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:0.2.0*255;1.06;
2018-05-21 20:53:19.534 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 0-0:C.1.0*255;66816007;
2018-05-21 20:53:19.537 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 0-0:C.1.6*255;391B;
2018-05-21 20:53:19.539 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 0-0:C.51.1*255;3;
2018-05-21 20:53:19.542 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 0-0:C.51.2*255;0160129064505;
2018-05-21 20:53:19.544 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:1.7.0*255;0.165;kW
2018-05-21 20:53:19.546 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:1.8.0*255;0006437.749;kWh
2018-05-21 20:53:19.548 [DEBUG] [meter.handler.Iec6205621MeterHandler] - DataSet: 1-0:1.8.1*255;0006437.749;kWh

My actual problem is to get the data (eg. actual power 1.7.0) to OpenHab for visualization.
In “default.items” I have added the following lines:

Number ActualEnergyConsumption "Zaehlerstand [%.3f kWh]" <energy> (meter) { iec6205621meter="meter;1-0:1.8.0*255" }
Number Power "Leistung [%.3f kW]" <energy> (meter) { iec6205621meter="meter;1-0:1.7.0*255" }

But the two items “Power” and “ActualEnergyConsumption” never will be changed to the values from the meter. The have the value NaN.
What was my mistake ?

Regards
Jens

Hello,
First of all my english is not that good.
I have installed openhab version 2.3.0 and wanted to try the binding iec 62056 21 with an ir-read head. I get this message in the openhab log:
Unresolved requirement: Import Package: gnu.io; version = “3.12.0.OH”
What are my requirements?
My system: Debian 9-bit 64-bit, openhab 2.3.0

Thanks a lot

Hi Jens,

I also try to integrate an MT174 meter to my openhab2 raspi.
The basic communication is running. I checked this with minicom.
Can you please give me an hint, how you got it running?
I tried the smartmeter addon and the IEC 62056-21 addon. Without success.

Thank you in advance
Andreas

1 Like

Hi,

I would like to test this binding with WIFI- RS bridge base on ESP8266.
Coudl you please tell if this could be use and if yes what i should put in Config - <meter-id1> .serialPort

Hi @hebel23 - did you finally get it going? I desperately went through forums, tried different things, but until now I only saw an iobroker - solution that should work (which I don’t want to use since I love my openhab Setup).

Hi @Armin1,

sorry its a long time ago. Unfortunately, I haven’t been able to get it to work yet.

Best regards
Andreas