DSMR binding for Austrian Smart Meters

Hi

Just found this thread and I am facing the same problems. I live in Styria (Graz) and recently got a sagemcom T210-D meter. After some analyzing I can confirm the the RJ11 uses 4 pins.
image
You will only get a signal on pin 5 when the 1 and 2 pin are on 5V. I can read out the data with an esp8266. I also use a logic level inverter with a BC547 as shown here:
https://www.google.com/url?sa=i&url=https%3A%2F%2Fgrodansparadis.com%2Fwordpress%2F%3Fp%3D5039&psig=AOvVaw3JgDgI2cval5wJfEJ6HBIu&ust=1639590622253000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCNC8_8eH5PQCFQAAAAAdAAAAABAJ
Now I will have to parse the telegram. Only page I found was this one:
http://www.weigu.lu/tutorials/sensors2bus/04_encryption/index.html
The problem I have now is, I get 475 bytes of data but ā€œlength of subsequent bytesā€ in the telegram shows 498 bytes. I did not get the decryption key yet, so I cant decode the telegram at the moment.
I can post my results when I am able to decode the stuff and parse it correctly. I already have written the code to parse it, but cant test it.

regards
Erich

Here is one telegram as hex string:
--------- Rawdata length=475 ----------
DB0853414735000382428201F2300000026BE9E7F19906C18A3F0AE0E12293AB
8BFED9D1433F508220AB0FA3056EDA8DF59F3D2C15A8892A55325E1B381EF43F
C08B919E9788E73F6E4B06386F5B0E6CED9B2574DEF04950120F8937661D20CD
95108508E9D307BD65F3342AAA849C8D7ADDE28FC88A7C6BEB923A12D75D2091
35D00198D0CCB41FA2146C82337EE77A1C0113B939E54AF427D26BE217D21A4F
83E001D864C67E0943158F712828986925B0207572D147A92C1C68A3FBA63E1D
CBD69EDB9A64B2799C3D17E4CC736C3CA389A48C9271A651C8FA25F7672F48C7
EA9AE06771AFFFDB1C8B83DA6F9B0193A3D4F982697B4D25213464C620F54D21
7567AF5A6DEF78495E5A86F366C1D64272D26DA19C68353BF72321AC7B1BCD51
90548E3E1DC706DEBCFBAE121FDFBD2C57AF8B41822677CA6EE68508C7F29F13
DF8DAE5AB594C7A96A46F9DCDC0AD4E93D147446504C33D0281AFBEC72AF2C2E
1BFBC90E61693477783BFC2FD8EA6ABE4565401D2CCF63335640AB72930E921C
DBE5446204271F950A4548CFC31878FABAEF4CAE7A4D38D7CA5899E71E83E27C
FB6C3DB7BCA021CAB1F47637E554A8214FC821639AD3DA44039D41FDA46FC1F0
AFABE52D8177A7248BCD582B861285CA4DEDCCB92A601D5C6E0C78

------- Start decoding: IV=53414735000382420000026B, length=498 ----------

You also might want to try the dsmr binding as it already supports the Austrian meters? (As mentioned here in this thread)

Fyi here is the latest on the p1 dongle that I am waiting for:

Q:

bitte um Auskunft, wann die hier beschriebene Smart Meter Kundenschnittstelle kƤuflich erwerbbar sein wird: Smart Meter-Schnittstelle: E-Wirtschaft ƶffnet Smart Meter fĆ¼r Kunden: Oesterreichs Energie

A:

ā€¦aktuell wird die Abnahme des Prototyps-0 abgeschlossen. Darauf aufbauend, beginnt mit Februar die Umsetzung des serienreifen Prototyps. Wir gehen davon aus, dass die Abnahme April/Mai durchgefĆ¼hrt wird. Parallel lƤuft schon die Beschaffung der Bauteile fĆ¼r das erste Kontingent. Hier sind wir aktuell stark von den Lieferzeiten der Hersteller abhƤngig.

Zusammengefasst: Die ersten Adapter liegen wahrscheinlich vor Mitte des Jahres nicht vor. ā€¦

hi there, also waiting for EVN. i mean they even published a doc, but still wonā€™t activate the P1 interface.

Hi!

Just tried to configure (with version 3.3.0) but i wasnā€™t able to figure out where to put my 2nd encryption keys! Did I miss something?

And maybe as additional information for other colleages in Austria:
There are two systems in use.

  • EVN (lower Austria) uses the Sagemcom meters with M-BUS interface (and ONE encryption key)
  • Styria uses Sagemcom meters with the P1 port with TWO encryption keys or Landis-Gyr meters with M-BUS interface (but also with 2 encryption keys)

Hi @mwildbolz ,
Just a remark to your additional information.
I am at EVN in lower Austria and having a Kaifa smartmeter where the M-Bus is seald, so just the P1 to use.
So it seams they are having different smartmeter in different areas, also within lower Austria.

Is there a plan to implement the possibility to add the additional 2nd encryption key in the configuration?

At the moment Iā€™m using a workaround and implementing this via an MQTT gateway. Itā€™s working, but itā€™s not a nice solution, especially because there is an openHAB binding existingā€¦

Do you have any information on how the encryption with 2 keys works? At the moment I have no plans to add it as I donā€™t know how I should implement it. If you can provide me with the information on how these keys are used I can see if this is possible to add to the binding.

At the moment, Iā€™m using the project already discussed earlier in this thread
tknaller/smarty_dsmr_proxy.

I add the additional encryption key via the parameter -a (see also decrypt.py#L75)

default="3000112233445566778899AABBCCDDEEFF", help="Additional authenticated data"

The default key seems to just work, if only 1 key is given by the energy supplier (like e.g. in the Netherlands)!

Afterwards Iā€™m transferring the data to MQTT via the project DSMR2MQTT

If itā€™s possible to add the 2nd encryption key also somewhere in this binding, then I think a communication directly from openhab would be possibleā€¦

Did you succeed in connecting the SAGEMCOM to openhab?
(same city, same infrastructureā€¦)

That was the information about the 2nd key I was looking for. Thanks. This seems fairly easy to add. Iā€™ll add this to the binding and will provide a jar for you to test in the near future. What version of openHAB are you running?

Sounds good.
Iā€™m running version 3.3.0

Br

Good morning Simon!

Yeah, data transfer is running (E-Netze Steiermark SAGEMCOM SmartMeter via P1 port).
But at the moment via a workaround (with smarty_dsmr_proxy and DSMR2MQTT) and not directly with the openHAB addOn. You can contact me directly if you need additional information!

But as for as I see, we should get it to work with the openHAB Addon in the near futureā€¦

Iā€™ve build a kar file with the an extra configuration parameter additionalKey. If you had the smarty bridge thing created via the UI you need to recreate it to see the new parameter. Kar files are very version specific. Iā€™ve built the kar file for openHAB 3.3.0 core (based on openHAB 3.4.0-SNAPSHOT add-ons code), and expect it to only work for 3.3.0: Release DSMR 3.3.0 updated version Ā· Hilbrand/openhab-addons Ā· GitHub Just drop the file in the addons directory and it should be seen by openHAB. It could be it doesnā€™t show up in installed bindings, but you should be able to add a bridge/thing in discovery.

Just tried - without success :frowning:

I saw in your commit that you used different spellings of additionalKey. Maybe this is the problem?
In the configuration you write additionalnKey (github link), later additionallKey (github link) and so on?!?

Error message in the log:

[WARN ] [.dsmr.internal.device.SmartyDecrypter] - Decrypting smarty telegram failed:
javax.crypto.AEADBadTagException: Tag mismatch!
        at com.sun.crypto.provider.GaloisCounterMode.decryptFinal(GaloisCounterMode.java:623) ~[?:?]
        at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:1116) ~[?:?]
        at com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1053) ~[?:?]
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853) ~[?:?]
        at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446) ~[?:?]
        at javax.crypto.Cipher.doFinal(Cipher.java:2260) ~[?:?]
        at org.openhab.binding.dsmr.internal.device.SmartyDecrypter.decrypt(SmartyDecrypter.java:216) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.SmartyDecrypter.processCompleted(SmartyDecrypter.java:193) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.SmartyDecrypter.parse(SmartyDecrypter.java:106) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.DSMRTelegramListener.handleData(DSMRTelegramListener.java:75) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.connector.DSMRBaseConnector.handleDataAvailable(DSMRBaseConnector.java:116) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.connector.DSMRSerialConnector.handleDataAvailable(DSMRSerialConnector.java:317) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.connector.DSMRSerialConnector.serialEvent(DSMRSerialConnector.java:276) [bundleFile:?]
        at org.openhab.core.io.transport.serial.rxtx.RxTxSerialPort$1.serialEvent(RxTxSerialPort.java:82) [bundleFile:?]
        at gnu.io.RXTXPort.sendEvent(RXTXPort.java:834) ~[bundleFile:5.2.1.OH1]
        at gnu.io.RXTXPort.eventLoop(Native Method) [bundleFile:5.2.1.OH1]
        at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:108) [bundleFile:5.2.1.OH1]

My configuration:

UID: dsmr:smartyBridge:0b2ad74b60
label: Smarty Meter
thingTypeUID: dsmr:smartyBridge
configuration:
  decryptionKey: xxxxx
  serialPort: /dev/ttyUSB0
  receivedTimeout: 30
  additionalnKey: xxxxx

Hopefully this is enough information to have a look atā€¦

BR from Austria,

MW

Doh :man_facepalming: sorry about that. Iā€™ve updated the binding with the correct naming (same link, only different kar file name to download from there).

Again no luck :frowning:

2022-09-05 21:21:38.555 [WARN ] [dsmr.internal.device.SmartyDecrypter] - Decrypting smarty telegram failed:
javax.crypto.AEADBadTagException: Tag mismatch!
        at com.sun.crypto.provider.GaloisCounterMode.decryptFinal(GaloisCounterMode.java:623) ~[?:?]
        at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:1116) ~[?:?]
        at com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1053) ~[?:?]
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853) ~[?:?]
        at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446) ~[?:?]
        at javax.crypto.Cipher.doFinal(Cipher.java:2260) ~[?:?]
        at org.openhab.binding.dsmr.internal.device.SmartyDecrypter.decrypt(SmartyDecrypter.java:216) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.SmartyDecrypter.processCompleted(SmartyDecrypter.java:193) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.SmartyDecrypter.parse(SmartyDecrypter.java:106) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.DSMRTelegramListener.handleData(DSMRTelegramListener.java:75) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.connector.DSMRBaseConnector.handleDataAvailable(DSMRBaseConnector.java:116) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.connector.DSMRSerialConnector.handleDataAvailable(DSMRSerialConnector.java:317) [bundleFile:?]
        at org.openhab.binding.dsmr.internal.device.connector.DSMRSerialConnector.serialEvent(DSMRSerialConnector.java:276) [bundleFile:?]
        at org.openhab.core.io.transport.serial.rxtx.RxTxSerialPort$1.serialEvent(RxTxSerialPort.java:82) [bundleFile:?]
        at gnu.io.RXTXPort.sendEvent(RXTXPort.java:834) ~[bundleFile:5.2.1.OH1]
        at gnu.io.RXTXPort.eventLoop(Native Method) [bundleFile:5.2.1.OH1]
        at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:108) [bundleFile:5.2.1.OH1]

I currently start the python script with following command-line, if this helps:

 /smarty_dsmr_proxy/decrypt.py E7E235650CCE6A383ED4849C9E087D16 -a A54FFB0357D0EF0A13A11A8209BC4695 --serial-input-port=/dev/ttyUSB0 --serial-output-port=/dev/pts/1

Iā€™ll send you test data via a personal message.

As a followup, the DSMR binding update to add support for a 2nd key as mentioned above has been updated and confirmed by @mwildbolz to work with 2 keys.

1 Like

Will this change be implemented in the official repository? Whatā€™s your plan regarding a pull request?

Thanks a lot for your support,
MW