core icon indicating copy to clipboard operation
core copied to clipboard

Add support for D0 protocol to EDL21

Open julred opened this issue 2 years ago • 34 comments

The problem

Dear all,

I installed EDL21 in order to visualize my smartmeter interface. My energymeter is from Logarex (see here the description: https://www.kommenergie.de/_Resources/Persistent/d/9/4/8/d9485ccfb652107fdab8a0f8b6bbe6fea8393547/Bedienungsanleitung%20Logarex%20Z%C3%A4hler.pdf )

I'm able to see all the values using CLI command cat /dev/ttyUSB1

edl21

I added also /dev/ttyUSB1 to the EDL21 configuation - but on the devices overview, I only got this message: 12-06-_2023_11-32-58

There are no logs available.

How can I receive all values inside Home Assistant (2023.6.1) - LXC Proxmox installation

What version of Home Assistant Core has the issue?

2023.6.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

EDL21

Link to integration documentation on our website

https://www.home-assistant.io/integrations/edl21

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

julred avatar Jun 12 '23 09:06 julred

same issue here is there a solution?

image

image

Sogge88 avatar Jun 12 '23 12:06 Sogge88

Could you activate the debug logging ("Debug Protokollierung einschalten") and send your log file?

StephanU avatar Jun 13 '23 04:06 StephanU

home-assistant_edl21_2023-06-13T05-19-08.967Z.log

i make a restart of HA and log this. Otherwise nothing was written in log.

Sogge88 avatar Jun 13 '23 05:06 Sogge88

error_log.log

I just reviewed this file. Lot of messages from viessmann integration, but also some lines regarding handling with /dev/ttyUSB1

julred avatar Jun 13 '23 05:06 julred

Hello, I have the same problem. No devices/entities are displayed or created.

Although, it worked once. 1 device and 3 entities were displayed. After a reboot of the Pi 3b+ the entities were gone again.

  • Baudrate 9600 is set (stty)
  • with the command cat -v /dev/ttyUSB0 I see cryptic characters (@, ^, B, F)
  • No readable values as shown from julred.

with chmod I see that the USB0 is read only. Is this a problem?

error_log_edit.txt

hawkeye79 avatar Jun 15 '23 06:06 hawkeye79

@Sogge88 Do you also have a Logarex energymeter like @julred? In both your logs it looks like a connection to the usb port is established, but no messages are received at all. I'm afraid this is beyond my capabilities. Maybe @mtdcr can help? :)

StephanU avatar Jun 16 '23 19:06 StephanU

Your devices speak D0 protocol, but the edl21 integration only supports the binary SML protocol at this time.

Someone would need to implement a parser and a configuration knob to select the protocol. D0 may require additional options like baud rate or whether to send an activation sequence or not. Since it's a text protocol (line-based), it may be even suitable for Python beginners looking for a challenge.

mtdcr avatar Jun 16 '23 19:06 mtdcr

Hi @StephanU Yes i have a Logarex: LK13BE803039

OK bur somehow the smartmeter send something because with stty -F /dev/ttyUSB0 9600 -parodd cs7 -cstopb parenb -ixoff -crtscts -hupcl -ixon -opost -onlcr -isig -icanon -iexten -echo -echoe -echoctl -echoke

And cat /dev/ttyUSB0. Data is read

Sogge88 avatar Jun 16 '23 20:06 Sogge88

I found this in the description of the smartmeter Optische Kommunikation EN 62056-21, Push, 9600 Bd

https://www.sw-l.de/assets/files/downloads/logarex-lk11-lk13.pdf

Sogge88 avatar Jun 16 '23 21:06 Sogge88

Hi, my problem is solved. My sensor did not have to sit centrally on the electricity meter, but rather eccentrically. After I had that, the integration ran.

But I still have one question: Is it possible to change the sampling time?

hawkeye79 avatar Jun 19 '23 11:06 hawkeye79

Hello,

I have a similar problem ('No values available in EDL21 #94460', referring also to 'EDL21 seems to be running (debug shows data) but not creating sensors or entities #91494'), no devices/entities have been created.

Configuration:

  • Raspberry Pi 4
  • Home Assistant 2023.6.2
  • Supervisor 2023.06.2
  • Operating System 10.3
  • Frontend 20230608.0 - latest

Transceiver: USB IR Lesekopf EHZ Lese-Schreib-Kopf Volkszähler Hichi Smartmeter, /dev/ttyUSB0

Debug-log: no entries related to the problem (so far I can see).

The weird issue is, that it worked already for a while, but all entries disappeared after reboot....

I would be happy to contribute to root cause analysis, but since I am a newbee, I need some advice.

Thanks Jay

Jay-0810 avatar Jun 19 '23 12:06 Jay-0810

Hi, my problem is solved. My sensor did not have to sit centrally on the electricity meter, but rather eccentrically. After I had that, the integration ran.

But I still have one question: Is it possible to change the sampling time?

Which kind of smartmeter are you using? Did you see serial outputs from your IR transmitter using e.g. cat /dev/ttyUSB0 ?

Your devices speak D0 protocol, but the edl21 integration only supports the binary SML protocol at this time.

Someone would need to implement a parser and a configuration knob to select the protocol. D0 may require additional options like baud rate or whether to send an activation sequence or not. Since it's a text protocol (line-based), it may be even suitable for Python beginners looking for a challenge.

Do you have any recommondations, how to start with this issue? Or an idea what needs to be extended in the existing parser?

julred avatar Jun 19 '23 14:06 julred

Smartmeter: GH305 cat /dev/ttyUSB0 --> '@@@f' and so on...

As I wrote: The weird issue is, that it worked already for a while, but all entries disappeared after reboot....

Regards Jay

Jay-0810 avatar Jun 19 '23 14:06 Jay-0810

If this integration has ever worked for you before, you have a different issue than OP.

You're also observing a different problem if your meter does not output ASCII characters as shown in screenshots above.

mtdcr avatar Jun 19 '23 14:06 mtdcr

@julred I have a Apator Lepus (SML protocol) and use the same setup how @Jay-0810 (USB IR Lesekopf EHZ Lese-Schreib-Kopf Volkszähler Hichi Smartmeter, /dev/ttyUSB0.) cat /dev/ttyUSB0 --> '@B' etc.

as I said, in my case, it was due to the positioning of the read head.

hawkeye79 avatar Jun 20 '23 06:06 hawkeye79

@hawkeye79 Thanks for pointing out. I saw the comment and changed the position several times; unfortunately without success. In meantime I tried another transceiver of same type, same issue: no sensors or entities have been created. I deleted integration, rebooted and created it again, no success...

Jay-0810 avatar Jun 20 '23 14:06 Jay-0810

Your devices speak D0 protocol, but the edl21 integration only supports the binary SML protocol at this time. Someone would need to implement a parser and a configuration knob to select the protocol. D0 may require additional options like baud rate or whether to send an activation sequence or not. Since it's a text protocol (line-based), it may be even suitable for Python beginners looking for a challenge.

Do you have any recommondations, how to start with this issue? Or an idea what needs to be extended in the existing parser?

Home Assistant prefers using asyncio over synchronous I/O, so for reading from a serial port you should use the serial_asyncio library. It it feels too complicated, maybe start with synchronous I/O (serial library) and move to serial_asyncio at a later point in time. You can use https://github.com/mtdcr/pysml/blob/master/sml/asyncio.py as an example. Try to run your code outside Home Assistant before trying to integrate it.

  1. Familiarize yourself with the protocol, for example by writing a script that parses a single hard-coded message.
  2. Read messages from the serial port line by line:
    • Ignore lines until you find a start of a frame ("/XYZ..." followed by an empty line)
    • Parse values contained in the frame into a structure, e.g. a dict compatible to what's called 'telegram' in edl21 with keys 'objName', 'value' and 'unit'
    • Put the stuctures into a list
    • Continue until end ("!") or until you find an unexpected line, indicating an error condition (another start, empty line or a line you can't parse)
  3. Find the electricity ID
  4. Create a structure for the message, e.g. a dict compatible to what's called 'message_body' in edl21 (store electricity ID in 'serverId', list from step 2 into 'valList')
  5. Implement a D0_Protocol class similar to SmlProtocol, implement an add_listener function, just without the unnecessary types argument).

In edl21/sensor.py, replace

self._proto = SmlProtocol(config[CONF_SERIAL_PORT]) self._proto.add_listener(self.event, ["SmlGetListResponse"])

with

self._proto = D0_Protocol(config[CONF_SERIAL_PORT]) self._proto.add_listener(self.event)

and remove assert isinstance(message_body, SmlGetListResponse) from event().

  1. Create a configuration option in edl21 to choose between the two protocols.

  2. Decide whether to publish the code in a library of its own or to include it in pysml.

I hope this helps to get you started.

mtdcr avatar Jun 20 '23 19:06 mtdcr

@julred Would you please change the title of this issue to e.g. "Add support for D0 protocol to EDL21"

StephanU avatar Jun 20 '23 19:06 StephanU

Hi is now someone doing this Integration of D0 Protokoll top edl21?

Sogge88 avatar Jun 21 '23 19:06 Sogge88

Hi, as mentioned, I'm a newbie. I'm not able to implement the proposed improvements, but I'd like to contribute by doing tests, for example....

Jay-0810 avatar Jun 21 '23 20:06 Jay-0810

Hi, got the same problem as OP. Would really appreciate if someone smarter then me would write that D0 Parser :)

In the meantime someone shown a workaround in this thread from 2 years ago, might be worth a look. https://community.home-assistant.io/t/reading-data-from-a-smart-meter-speaking-d0/304258

Dvaina avatar Jun 26 '23 20:06 Dvaina

https://community.home-assistant.io/t/edl21-adding-support-for-logarex/343883

Megachip avatar Jul 29 '23 08:07 Megachip

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Not cleared yet. Needs to be Open for further discussion

julred avatar Nov 01 '23 06:11 julred

Would love to see the D0 integration, too. So please reopen this issue.

Any hints are greatly appreciated - IÄm not a Python expert, but would invest a few hours to integrate this...

3dh-de avatar Nov 23 '23 23:11 3dh-de

I need a D0 integration also. Using the Logarex counter and a Weidman IR Module availble on serial port (/dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DK0DW1X1-if00-port0).

Maschine20 avatar Nov 26 '23 13:11 Maschine20

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Would love to see the D0 integration, too. So please reopen this issue.

Any hints are greatly appreciated - IÄm not a Python expert, but would invest a few hours to integrate this...

Does this information help? https://github.com/home-assistant/core/issues/94460#issuecomment-1599404122

mtdcr avatar Feb 24 '24 14:02 mtdcr

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.