Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for D0 protocol to EDL21 #94460

Open
julred opened this issue Jun 12, 2023 · 29 comments
Open

Add support for D0 protocol to EDL21 #94460

julred opened this issue Jun 12, 2023 · 29 comments

Comments

@julred
Copy link

julred commented Jun 12, 2023

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

@home-assistant
Copy link

@Sogge88
Copy link

Sogge88 commented Jun 12, 2023

same issue here
is there a solution?

image

image

@StephanU
Copy link
Contributor

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

@Sogge88
Copy link

Sogge88 commented Jun 13, 2023

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.

@julred
Copy link
Author

julred commented Jun 13, 2023

error_log.log

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

@hawkeye79
Copy link

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

@StephanU
Copy link
Contributor

StephanU commented Jun 16, 2023

@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? :)

@mtdcr
Copy link
Contributor

mtdcr commented Jun 16, 2023

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.

@Sogge88
Copy link

Sogge88 commented Jun 16, 2023

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
Copy link

Sogge88 commented Jun 16, 2023

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

@hawkeye79
Copy link

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?

@Jay-0810
Copy link

Jay-0810 commented Jun 19, 2023

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

@julred
Copy link
Author

julred commented Jun 19, 2023

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?

@Jay-0810
Copy link

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

@mtdcr
Copy link
Contributor

mtdcr commented Jun 19, 2023

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.

@hawkeye79
Copy link

@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.

@Jay-0810
Copy link

@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...

@mtdcr
Copy link
Contributor

mtdcr commented Jun 20, 2023

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.

@StephanU
Copy link
Contributor

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

@julred julred changed the title No values available in EDL21 Add support for D0 protocol to EDL21 Jun 21, 2023
@Sogge88
Copy link

Sogge88 commented Jun 21, 2023

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

@Jay-0810
Copy link

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....

@Dvaina
Copy link

Dvaina commented Jun 26, 2023

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

@Megachip
Copy link

@issue-triage-workflows
Copy link

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.

@julred
Copy link
Author

julred commented Nov 1, 2023

Not cleared yet.
Needs to be Open for further discussion

@github-actions github-actions bot removed the stale label Nov 1, 2023
@3dh-de
Copy link

3dh-de commented Nov 23, 2023

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...

@Maschine20
Copy link

Maschine20 commented Nov 26, 2023

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).

@issue-triage-workflows
Copy link

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.

@mtdcr
Copy link
Contributor

mtdcr commented Feb 24, 2024

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? #94460 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants