Integrate Power Meter Data into openhab

Hi everyone,

I am trying to integrate/read the data from my two power meters into openhab. One of the power meters is used for measuring the produced electritiy in the PV system. The other meter is measuring the connection to the public grid in bith directions. It counts with two separate counter the energy consumed from the grid and the energy sold to the grid. The first meter is a Hager EHZ361LA which is sending data every 1-4 seconds in D0 format without the need to request the data by sending a command to the meter. The second meter is an EMH eHZ FW8… modell which is also sending in intervals without the need to request that output but this meter is sending in SML format.

Last weekend I dot two optical interfaces for the connection to the meters from volkszaehler.org and connected them to the meters and the Raspberry Pi2 which is also running openhab. Both interfaces work and with minicom I can see the D0 ASCII or SML binary data that is being received. First I tried the IEC 62056-21 Binding in openhab but could not get it to initialize any items. I found IEC 62056-21 timeout thread on knx-user-forum which exactly describes the messages i see in openhab log but I think my meter is simple using the discussed Mode D instead of the implemented Mode C while the TO in the thread was using an SML meter.

In minicom with an 9600 8N1 connection I can see the data repeat every few seconds in the same format:
/HAG5eHZ010C_EHZ1NA12

1-0:0.0.0255(xxxxxxxxxxxxxxxx)
1-0:2.8.0
255(066320.9872)
1-0:96.5.5255(82)
0-0:96.1.255
255(xxxxxxxxxx)
1-0:32.7.0255(236.34V)
1-0:52.7.0255(236.79V)
1-0:72.7.0255(236.97V)
1-0:31.7.0255(001.07A)
1-0:51.7.0255(001.08A)
1-0:71.7.0255(001.07A)
1-0:21.7.0255(-00167W)
1-0:41.7.0255(-00168W)
1-0:61.7.0255(-00167W)

… etc. (there are more OBIS-values in the 1-0:96:50.0*-range, in which i can not find any purpose/meaning)

Because I could not get the binding (with different combination of cfg-settings) to work I reverted back to read the data from the interface and interpret it with a bash script in a 1-minute cronjob. The found values (total consumed kwh, current power produced W) are being send to openhab via curl POST to the item-state. But of course I would prefer to use a proper openhab binding with direct update in openhab.

For the second meter I found SMLReader Binding which has been moved to New Openhab Pull Request but I could not find a Build (JAR-File) anywhere to download and test it. So I also read the meter with a bash script and simple parse the found hex data on 3 different byte-offset positions into decimal numbers and send those to openhab also via curl POST.

Does anyone have further ideas on how to use the IEC 62056-21 binding or where to find a version of SMLReader to test (my openhab installation is running on 1.7.1)?

Hi knud_baier,

i’m going to provide a download link where you can get the 1.7.0 version of the SmlReaderBinding this afternoon…

please be patient :smile:

As promised, here’s the link:

https://onedrive.live.com/redir?resid=D4CDD8879A794E41!93204&authkey=!ANLUySVnscVwQ-k&ithint=file%2Czip

Please follow the configuration example from my pull request on github.

Have Fun!

1 Like

Hi gilhmauy,

I’ve also tested the Binding on Beaglebone Black, Ubuntu 14.04 LTS, volkszaehler IR TTL Reader on ttyO1 and an ISKRA MT681 SML Power Meter. I’ve got the following Stacktrace:

[ERROR] [.service.AbstractActiveService] - Error
while executing background thread SmlReader Refresh Service java.lang.ClassCastException:
org.openmuc.jsml.structures.Unsigned32 cannot be cast to org.openmuc.jsml.structures.Integer32

at org.openhab.binding.smlreader.internal.SmlValue.getValue(SmlValue.java:145)~[na:na]
at org.openhab.binding.smlreader.internal.SmlValue.toString(SmlValue.java:114)~[na:na]
at org.openhab.binding.smlreader.internal.SmlDevice.printInfo(SmlDevice.java:104) ~[na:na]
at org.openhab.binding.smlreader.internal.SmlDevice.populateValueCache(SmlDevice.java:210) ~[na:na]
at org.openhab.binding.smlreader.internal.SmlDevice.readValues(SmlDevice.java:267) ~[na:na]
at org.openhab.binding.smlreader.internal.SmlReaderBinding.execute(SmlReaderBinding.java:98) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156)~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

I’m not a Programmer, so can you provide a solution/fix for this, please.
My 2. comment: The param “smlreader:refresh=60” in openhab.cfg means seconds, but in the code, it means milliseconds! Can you also check this, please!
Thanks in advance!

Hi @skonline!

Thanks for your feedback. I’m trying to fix the issue as soon as possible and provide the updated binding within this post.

Hi @gilhmauy,

Is there already a solution for this issue?

Hi,

are there any news about this binding? Or is it dead bevor release?

Bests

Sorry for the delay, but from private and professional reasons i’ve currently no time to have a look at the plugin. I’ll fix the issues as soon as posssible and provide a new version…

1 Like

Hi,
if I am wrong, pls excuse, but what I did with my external power meter was similar. I used the exec binding to execute a bash script every minute.
The returned value (Number item) was stored via mysql persistence in a database.
Same I did for gas- and water consumption.
Cheers
Björn

Hi,

is there any timerange for fixing the issue with the ISKRA MT681 SML :grinning:

br
portboy

I merged your plugin against my local source checkout of OH 1.8.2 and compiled it, which worked quite well. I have problems though to see any output in the logs for this plugin, even though i have gnu.io.rxtx.SerialPorts=/dev/ttyUSB0 set.

smlreader:refresh=10
smlreader:MT681.serialPort=/dev/ttyUSB0

with vzlogger from volkszaehler.org i was able to read SML data earlier today:

[Mar 24 18:15:34][mtr0] Got 7 new readings from meter:
[Mar 24 18:15:34][mtr0] Reading: id=1-0:1.8.0*255/ObisItentifier:1-0:1.8.0*255 value=31436.60 ts=1458843334519
[Mar 24 18:15:34][mtr0] Reading: id=1-0:1.8.1*255/ObisItentifier:1-0:1.8.1*255 value=31436.60 ts=1458843334519
[Mar 24 18:15:34][mtr0] Reading: id=1-0:1.8.2*255/ObisItentifier:1-0:1.8.2*255 value=0.00 ts=1458843334519
[Mar 24 18:15:34][mtr0] Reading: id=1-0:16.7.0*255/ObisItentifier:1-0:16.7.0*255 value=503.00 ts=1458843334519
[Mar 24 18:15:34][mtr0] Reading: id=1-0:36.7.0*255/ObisItentifier:1-0:36.7.0*255 value=208.00 ts=1458843334519
[Mar 24 18:15:34][mtr0] Reading: id=1-0:56.7.0*255/ObisItentifier:1-0:56.7.0*255 value=122.00 ts=1458843334519
[Mar 24 18:15:34][mtr0] Reading: id=1-0:76.7.0*255/ObisItentifier:1-0:76.7.0*255 value=171.00 ts=1458843334519

and opening a screen /dev/ttyUSB0 also shows some binary data, so in general there is data on my USB reader.

Any ideas where to start to debug?

okay, using your 1.7.0 jar gives me way more output, even though i get no data into openhab displayed ATM.

Hi

you may also try the existing https://github.com/openhab/openhab/wiki/IEC-62056---21-Meter-Binding

just delivered a fix to also handle above OBIS formats

BR
kreutpet

I also tried to build from source by myself and found out that there was some configuration stuff missing. The bundle was not executing anything!
I created a PR for this

I’ve created a PR for openhab 2 binding to read a SML Meter: https://github.com/openhab/openhab2-addons/pull/2167

If someone is interrested, please Install it from the Market (install market Extensions and Filter addons for “market”, since 2.1.0 Snapshot).
Amy Feedback is appreciated!

Thanks
Matthias